Adding Lives in the Game HELP

Hi all, im newbie here. So i started with the first app from the lessons here - “Balloon tap”

So, i did it, but i’ve simple added other things at it. Now i want to add lives in the game. The idea is that: when the balloon touches the spikes, one live goes down. And when we are out of lives, the score goes to 0. How i can code this? Please help me!

Thanks for the attention!

Hi
 

You can include the lives counter in the function which detects collision with the spikes. If collision with spikes is true then check if lives == 0 to end the game else just live = lives - 1. 

if ( lives \>= 1 ) then -- gameover when lives value reaches 0        lives = lives - 1 -- continue playing by moving the balloon at the start position else lives = live - 1       -- show gameover text, when lives value == 0 end

 

Thanks, the problem was at the collision part of the code, but i think that i’ve fixed it :slight_smile:

Anyway, thx :slight_smile:

Hi
 

You can include the lives counter in the function which detects collision with the spikes. If collision with spikes is true then check if lives == 0 to end the game else just live = lives - 1. 

if ( lives \>= 1 ) then -- gameover when lives value reaches 0        lives = lives - 1 -- continue playing by moving the balloon at the start position else lives = live - 1       -- show gameover text, when lives value == 0 end

 

Thanks, the problem was at the collision part of the code, but i think that i’ve fixed it :slight_smile:

Anyway, thx :slight_smile: