GML Visual Lives GameMaker

M

malki_2020

Guest
Hey guys! So I recently started making this game, its very easy to play but my game keep stuffing up on the lives part.
Anyways i made the lives to be deducted every time the player collides with a bomb and here's how it looks,

the "draw the lives as image" block draws the remaining lives
It'd be great if i could get your opinion this!!!!!!!!
shoutout to @Roderick for helping with the formatting!! :)
 

Attachments

Last edited by a moderator:

curato

Member
It has been a while since I saw that version, but looking at the logic. It seems like when you are hit you are subtracting from lives multiple times and therefore have no lives left after being hit with a bomb. If you are getting hit one time and then die that is your issue. also the draw lives should be in the draw event of an object that is always going to be there like the player object or if you have an object set up for managing the game.
 
M

malki_2020

Guest
It has been a while since I saw that version, but looking at the logic. It seems like when you are hit you are subtracting from lives multiple times and therefore have no lives left after being hit with a bomb. If you are getting hit one time and then die that is your issue. also the draw lives should be in the draw event of an object that is always going to be there like the player object or if you have an object set up for managing the game.
That is definitely the problem!!!! Thank you so much for the help :)
 
M

malki_2020

Guest
You're setting the lives to -1. If you have fewer than 3 lives, then you have -1 lives. What was that meant to accomplish?
I guess it means i have zero lives and that's game over, but i think either the sequencing is wrong or i need to add something to get it right, but thank you for that question, I am definitely thinking.... :)
 

curato

Member
Yes take everything after the relative -1 out of that even and you just need the draw lives in the draw event of the player.
 
Read your code. It's in plain English! How does "if lives are less than three, set lives to -1." make any sense? You'll always have -1 lives after being hit, hahah! ;)

Make sure to notice the difference between setting variables with and without relative checked, too. If lives starts at 3 and you say "set lives relative -1," lives will be equal to 2. If you just set lives to -1 without checking the "relative" box, lives will just be set to negative one! Big difference!

Honestly though, I'd move away from drag and drop as soon as possible. After a few days of acclimation, I think code is actually easier to read and less prone to errors like this. Good luck!
 
Top