• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

live not working in space rocks

Q

quirkylemon103

Guest
so i finished the tutorial for space rocks except whenever you hit an asteroid you either lose 2 lives and die or you just die
here is the code
GML:
if (lives  <= 0)
{
instance_destroy(obj_ship)
audio_play_sound(snd_lose, 1, false);    
room_goto(rm_gameover)
}
this is in obj_game
Code:
lives -= 1;
this in the collision event between ship and asteroid
also I've checked to see if i have duplicates anywhere and i didn't get any when i
used the cctrl shift f
 
Last edited by a moderator:

flyinian

Member
so i finished the tutorial for space rocks except whenever you hit an asteroid you either lose 2 lives and die or you just die
here is the code
GML:
if (lives  <= 0)
{
instance_destroy(obj_ship)
audio_play_sound(snd_lose, 1, false);   
room_goto(rm_gameover)
}
this is in obj_game
Code:
lives -= 1;
this in the collision event between ship and asteroid
also I've checked to see if i have duplicates anywhere and i didn't get any when i
used the cctrl shift f
Where is your lives variable located?

Provide the code on how you're losing lives when hit by asteroid.
 

Rob

Member
Collision events run every step and there are usually 30-60 steps EVERY second, depending on your room speed, so what's probably happening is you lose all your lives in 2-3 steps (the code runs 2-3 times, but you just see it as instantaneous because it's so quick).

You could destroy the asteroid when it collides with the player object, which would be the easiest to set up for you I think (just put a collision event in the asteroid object, and just use

GML:
instance_destroy();
to get rid of it)
 
Top