The Challenge
Start by clicking on the ‘Download Resources’ button above this text. You should find the file ‘Brick Invaders.capx’. Open this file in Construct 2.
This week, we’re going to give the player more opportunities to clear the screen of blocks.
Read it to me: Challenge How to Start
Currently, the player only gets one “turn” to destroy the blocks. That is, they have one ball to fire – when the ball is lost, the game ends. This is a little tough, so we’re going to allow the player a number of turns. It’s up to you how many the player should have, but somewhere from 3 to 5 should work well. Create a “TurnsLeft” variable that decreases every time the player loses a ball. If the player has lost a ball and has no turns left, the game is over. Otherwise, a new ball spawns on the paddle and the game continues.
Areas of difficulty:
If you don’t know where to find the event handling the ball being lost, look at the bottom of the ‘Ball Collisions’ group for an event that “destroys” the ‘Ball’ object. The ball should still be destroyed, but the other actions in this event should only take place if ‘TurnsLeft’ is zero. Remember, you can add a sub-event by right-clicking on an event.
To spawn a new ball on top of the paddle, you’ll need an action belonging to the ‘Paddle’ object, under the ‘Misc’ section.
If you like, you can try using the ‘Pin’ behaviour on the ball to stick it to the paddle until the player clicks.
Errors and resolutions:
When I restart the game, I lose after one turn!
Make sure that when the game restarts (from losing or winning), you include an action that sets ‘TurnsLeft’ back to its original value.
The player has infinite turns!
Make sure that when the ball is lost AND ‘TurnsLeft’ is greater than zero, you subtract 1 from the ‘TurnsLeft’ variable. Remember, you can add a sub-event by right-clicking on an event.