Block Dodger

Use the arrow keys to move a character through an onslaught of projectiles. Try to see how long you can survive! Press space to play again if you get caught.


Play this demo in full screen.

1) Create a character sprite.


Play this demo in full screen.

2) Make your character move with the arrow keys.


Play this demo in full screen.

3) Create an obstacle for your character to dodge. Have this obstacle start at a random point along the border of the screen.


Play this demo in full screen.

4) Have the obstacle point towards your character when it spawns.


Play this demo in full screen.

5) Make the obstacle move at a constant speed.


Play this demo in full screen.

6) Have more obstacles be created every few milliseconds.


Play this demo in full screen.

7) Create a timer variable that starts at at 0. Every one second, have the timer increase by one. Display the timer to the player.


Play this demo in full screen.

8) Have the game freeze if the character touches an obstacle, and come up with a way to let the player know the game is over.


Play this demo in full screen.

9) Make it so that if the game ends, pressing the space key will reset the timer, empty the obstacle list, and unfreeze the game.


Play this demo in full screen.

Challenge: Can you find a way to prevent your character from being able to move off screen?


Play this demo in full screen.