7.5 A little Game

  1. Create a triangle at the bottom of the screen. This triangle can be moved back and forth with the arrow keys.
  2. Add a container for the class Vec2. Every time you press the space bar, you add an element on the location of the triangle.
  3. Increase the y value of every container element in the Update function.(Use Time.d()!) If an element reaches the top of the screen, remove it from the container.
  4. Draw all elements on the screen in the Draw() function.
  5. Create a second container for circles. Every second a circle must be added somewhere at the top of the screen.
  6. Move all circles down in the Update() function.
  7. Show all circles in the Draw() function.
  8. When a circle hits a Vec2 from the other container, both must be removed.
  9. When a circle hits the triangle, ‘Game Over’ must be shown on the screen.

You could go even further with this game. Don’t create new circles after the game is finished, and disable movement and shooting. Circles might move faster the longer you play, a score can be shown or you might give the player more than one life.

And instead of triangles and circles, images might be used. Have fun!