BrickBreaker is a game that I made using Unity and C#. I’ll explain the various components of the game for you.
The start menu consists of two buttons “Start” and “Quit”. Pretty self explanatory.
In level one the player is introduced to two different kinds of blocks “red” and “green.” Green blocks can be destroyed with just one hit, while red blocks take two hits to destroy.
Behind the scenes a couple things are going on to ensure nothing weird happens when the player is moving the paddle around. If you take a look at the walls you can see that there are barriers that I made using Unity colliders. These barriers prevent the ball from escaping the screen and also prevent the paddle from being dragged off the screen. The colliders also support Unity physics and deflect the ball when the ball hits them.
When a brick is hit with the ball, the sprite image is changed to indicate the brick is damaged. This is vital for the player so that he has feedback on how he is doing in the game. Depending on the brick color, “green”, “red”, “blue”, the brick will have various stages of damage sprites. An array holds these sprites and increments the pointer as the brick gets more damaged.
In level two I changed the background as well as adding the stronger blue bricks which take 3 hits to destroy.
In level three I made things more tricky by adding a lot of blue bricks and spacing out the green bricks since it’s the last level.
One bug I found during development was that sometimes the ball would get launched perfectly vertical and no matter how you hit the ball it would not change direction. To fix this issue I used the Random.Range() function to generate some random numbers that I could use to slightly change the balls velocity whenever it collides with something. This randomness is more realistic and prevents boring game loops like the vertical collision loop.