1/13-1/17

6.1.3: Breakout

The last part of the game is to get collisions working. You should remove bricks when the balls collide with them. This is VERY similar to bouncing the ball.

You just need to use the getElementAt(x, y) function to see if there is an element where the ball is. If the element is not null, then you can remove it with the remove function.

You also need the ball to bounce up if it collides with the paddle

You want to check the four corners around the ball to see if there is an element there.

Last, there are just some miscellaneous things you can do:

  • Pause the ball when it gets reset until you click. Kind of like the Pause Ball exercise.
  • Stop the game after the ball falls to the bottom 3 times.
  • Stop the game when all the bricks are removed.
  • Display messages on the screen when you win or lose.

Then, you can just go crazy with extensions like these, if you’re feeling up to it.

  • Display a score.
  • Add power ups.
  • Add cheat codes.
  • Add multiple difficulty levels.
  • Anything else that you can think of

Leave a Reply

Your email address will not be published. Required fields are marked *