Matthew's Coding Blog: Brick Breaker Interactivity
- mziegen
- Nov 16, 2021
- 1 min read
For the unfinished project, recreating my own brick breaker game was my focal point. As previously mentioned, I have not yet finished the project, but am moving along just fine in the matter. I've created a paddle for my ball to hit off of (keyboard), a ball, 36 bricks (as template examples), a game over screen if one fails to keep the ball from hitting the ground, and a reset button (mouse code). All rectangles are set to 50x50, the ball is 30x30, and our paddle is 70x8. On a 600x600 canvas, on function setup I have set my ball to start at 300 on the x-scale and 200 on the y-scale because it gives the player more time to react and place the paddle under the incoming ball. The paddle is set at 300 on the x-scale and 580 on the y-scale. The ball moves at a speed of 4, both along the x and y scales. Since I have not found a way to make blocks disappear once hitting them, I have set the ball to contact the lowest layer and bounce back by setting the high point to 160. The only way the game can end is if the ball goes above 600 on y-axis in which the reset button is set to restart the game.
The code:
The game:

Comments