We created our first game in the previous chapter. If you still remember what we did there, we used instance variables to do two things: flap the plane and make the ground scroll. We used only Boolean type instance variables to do what we want, while there are still two other variable types.
These other types can be used to manipulate the state of an object; if you ever see Mario becoming big after eating a mushroom or becoming invincible after getting a star, then you've seen the example of changing the state of an object. We will create something similar in this chapter.
In this chapter, we will cover the following topics:
Just like the previous chapter, we will start this chapter by making a design of the game we want to make. You probably would have guessed by reading the chapter title that we are going to make a breakout clone. Breakout is a game where you move a paddle in the bottom part of the screen to bounce a ball up to destroy blocks. However, some blocks will be able to add some variation to the gameplay. Let's start with the following criteria:
This is pretty much our design for a breakout clone; we will use this design to create our example game for this chapter.
Now, before we actually get our hands on Construct 2, I want to lay out the design of this game in more detail. First, I want to explain the way in which this game rewards the players. The idea I had in mind was to make each block contain a value so that every time it's destroyed, the score will be added by the same value. However, as the number of blocks in a level will be the same for everyone playing, which would result in everyone getting the same score, I decided to add an element to the final score calculation that would vary the score. So, I added the time it takes for a player to finish a level to the score calculation formula.
However, this is still not enough. What if there are people who cleared a level at the same time? Or is it only slightly slower than the other? The gap between each score will be so small that it will be easy to beat the higher ranking player. Also, the skilled players will eventually be able to beat the level in the fastest possible time, making a score limit to the game. To prevent this, I decided to give the game special power ups that can increase the scores. These power ups should appear randomly, and once they appear, they should disappear within a few seconds.