Step 3

Ending the game if the player has no lives left

Now that we've checked for collisions and updated the number of lives, we need to check if the player actually has any lives left, and if they don't have any lives left we need to reset their lives back to 4, and send them back to the starting level.

Grab these blocks and arrange them as shown:

if (from Control) number lives (from Variables) < ( = from Operators) number (0) (from Operators) go to first level (from Control) set number lives to (from Variables) number (0) (from Operators)

Now save the script, and play your game.

You might notice that when you crash you lose all your lives, and quickly lose the game. The next thing we'll do will be to make the player character into a ghost for a second when the player loses a life -- it'll go slightly transparent and become temporarily immune to being damaged.

results matching ""

    No results matching ""