Chocobreak Tutorial - Step 11
Step 11: Completing the game
If you run your game, you will see that the score and lives are now displayed, but they do not change : we have to enter the actions that will modify them.
Go back to the event editor.
The score
We want to add points to the score when the ball destroys a brick. As you can imagine, we have to add a new action on the line where the collision between the brick and the ball is handled. Locate this line, and move your mouse horizontally under the Player 1 object. Right click on the empty square located at the intersection. This opens the Player 1 object actions menu. As you can see, this menu contains options to change both the number of lives, and the score. Select the "Add to score" option.
Note: As you have noticed, the action "Add to score" is located under the Player 1 object and not under the Score object.
A new dialog box appears : the expression editor. This dialog box allows us to perform calculations (and even complex ones) in Clickteam Fusion 2.5. For the moment, just enter the number 100 in the white edit zone, and click on OK.
A new action is inserted. If you try your game you will see that the score now increases as the bricks are destroyed.
The lives
The Lives object automatically starts with three lives, just the number we want!
Let's think a little. We want to subtract one life when the player misses the ball and it goes out the bottom of the playfield. This gives us the following event : "When the ball leaves the area in the bottom / Subtract one life from the player". So we need to enter a new line of event.
You certainly know the procedure by now : click on New condition, and right click on the ball to open its conditions menu. Now locate the "Test position of BallGolden " option, this is the one we want to use. It immediately opens a new dialog box for you to choose which side of the frame to check. Select the "Leaves in the bottom" only, and click on OK.
We now have our new line:
We can now enter the action to subtract one from the number of lives. You should be able to do it yourself : locate the square below the "Player 1" object in front of our new condition, and right click. Then choose "Subtract from number of lives", and enter 1 in the expression editor.
Note: As you have noticed, the action "Subtract from number of lives" is located under the Player 1 object and not under the Lives object.
We could also make a "loosing" noise when the player looses one ball : open the Sound object actions menu, and choose Play sample. Locate the directory where we extracted the sounds before and select the file : "DOWN01.WAV". Before closing the sound picker, tick the small checkbox in the bottom right of the box "Uninterruptable" : the sound will play fully and will not be interrupted by other sounds.
If you launch your game, you can see that everything works very well, except for one thing : when the ball leave the play area in the bottom, it is lost forever! We should program an action to bring it back! Let's do it.
Locate your mouse on the same line than before, under the BallGolden object, and right click. In the Action menu of the ball, locate the option "Position" / "Select position". This option automatically displays the frame for you to point to the new position of the object. Position the flashing cross in the middle of the frame, under the bricks, and click on OK.
We have now entered a new action that re-positions the ball automatically in the center of the screen when it disappears at the bottom. Try your game : it works, but you immediately notice that it is very difficult to grab the ball when it comes back in the play area : it goes toward the bottom at a high speed, and most of the time the player misses it.
What we need to do, is just after repositioning the ball in the play area, is to change its direction to the top. This can be done via a simple action : locate the checkmark with the position action, and right click on it (nothing prevents us from having more than one action per checkmark). In the action menu, select the option "Direction" / "Select direction". This opens a dialog box similar to the one we have found when setting the movement property of the ball. Select only the directions that point upward : one direction will be chosen for the ball to take at random during runtime.
If you test your game, you notice that the gameplay is now very good! Looks like a game, ey? It is!
Spread the word!
You can share this document using the following buttons.