Chapter 4. Making a Breakout Clone

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:

  • More ways to use instance variables
  • What a constant variable is
  • What an expression is and how to use it
  • How to make an object bounce off other objects
  • What sub-events are

Creating the design

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:

  • Elevator pitch: An elevator pitch is the description of your game as you would explain it to someone in an elevator, short and concise. This game is a game where players move a paddle to bounce balls off to destroy blocks. Some of the blocks will have special effects to change the balls or the paddle.
  • Theme: The theme for this game is puzzle.
  • Genre: The genre for the game is puzzle game.
  • Challenges: These are used to destroy all of the blocks in a level.
  • Rewards: Players are given scores depending on what blocks are destroyed and how long they take to complete a level; some blocks will also change the score.
  • Winning condition: All the blocks are destroyed.
  • Losing condition: Each time a ball falls below the game screen, the player loses a life; if the player loses all three lives, then they lose the game.
  • Dynamics: Dynamics are the rules that apply in the game; they form the instructions on how the game is played. For our game, the dynamics are as follows:
    • The ball bounces off the paddle, the blocks, and the three sides of the game area
    • The ball doesn't bounce in the bottom part of the game area
    • The paddle can only move to the left and to the right
    • Some of the blocks will produce a special effect when destroyed
  • Main game flow: This defines how the game plays from beginning to end, from the start of the level until either the player wins or loses:
    • The ball moves downward at an angle at the start of the level
    • If the ball falls into the bottom part of the game area, the player loses a life
    • If the ball bounces off one of the blocks, that block is destroyed
    • For some blocks, a special effect will occur if it's destroyed
    • Some blocks will need to be bounced off more than once to be completely destroyed
    • If all the blocks are destroyed before the player loses, the player wins

This is pretty much our design for a breakout clone; we will use this design to create our example game for this chapter.

Designing the reward system

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset