Pong/Breakout game: More progress

I’ve made even more progress with my game. I have added blocks to the game which both players need to break.

Here is how it looks so far.

I used this tutorial to set up the blocks and also to script the function that causes them to destroy on contact with the ball (Noobtuts.com. n.d.). However, I have deviated from this tutorial in several ways.

Firstly, the tutorial suggests that I create five separate sprites for each coloured block. However, I discovered that the colour of the block can be controlled using the Sprite Renderer component.

This will be particularly useful as I want the blocks to be random. Additionally, later on I want to update the gameplay so that the balls change colour every few seconds and when the colour of the ball matches the block it hits, the player gets bonus points and a power-up.

To randomise the colour of each of the blocks, I searched various forums to find scripting that can help me do this.

I was able to find the following script (Stack Overflow. 2020).

This script allows me to assign colours to each block from a list of five options. I eventually want to learn how to do this in a way that allows me to select the exact shade of each colour using the RGBA numbers, as the colours that display in the game at the moment are fairly bog standard and unappealing. If anyone reading this knows of a solution to this, please feel free to comment on this post.

As you will see towards the end of this video, one of the paddles rotates the wrong way round because of how it comes in contact with the ball. I have since resolved this by applying a component called Rotation Constraints (Docs.unity3d.com. 2019) and using this to freeze the rotation, so that the panel stays fixed in its rotation.

Next things I will need to do for this game are as follows:

  • Scoreboard
  • Time limits
  • Unlocking power-ups
  • AI opponent
  • Changing a colour in real time
  • Sound effects
  • Background images

References

Docs.unity3d.com. 2019. Unity – Manual: Rotation Constraints. [online] Available at: <https://docs.unity3d.com/2018.3/Documentation/Manual/class-RotationConstraint.html> [Accessed 8 February 2021].

Noobtuts.com. 2021. noobtuts – Unity 2D Arkanoid Tutorial. [online] Available at: <https://noobtuts.com/unity/2d-arkanoid-game> [Accessed 8 February 2021].

Stack Overflow. 2020. How to assign random Colors in unity?. [online] Available at: <https://stackoverflow.com/questions/62301020/how-to-assign-random-colors-in-unity> [Accessed 8 February 2021].

One Reply to “Pong/Breakout game: More progress”

Leave a Reply

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