SOLVED [problem] tracking life's trough different rooms

C

casperk

Guest
for school i have to make a game in gamemaker 1.4 . we work in teams and one of my teammates suggested to make a secondary room where you have to answer a question to respawn at the current level and if u answer it wrong you got to start at level 1 again. we wanted to give you a second try. i mean with that that you can answer the question ones wrong and still go to the current level. if you then answer the question wrong you go back to the first level. i have tried this with lives and health bars but i always go back to the current level and not to level 1. does someone know an solution for this?

edit: i forgot the pictures of the "code" although it isnt realy code.
 

Attachments

Last edited by a moderator:

Mr Magnus

Viking King
Make sure that in the "current level" you're not resetting the lives. Wherever you first said "lives = 3" or whatever make sure that code can only run once.

Beyond that Tsuka is right, we can't tell what is wrong with your code without knowing what you're doing exactly.
 
C

casperk

Guest
We can't really diagnose a problem unless you show us the code that's involved... ;)
yeah i forgot about that it was kinda late yesterday when i was working on it and i just wanted it to work. i aded pictures of the "code"
 

Xer0botXer0

Senpai
Portion 1I'm a real rookie at D&D so take this with a grain of salt, but of your three images, 1 image shows that at the no more lives event 2 things happen, you check if lives are == 0, and if so then you use room_goto(lvl1); ..

Portion 2

That makes sense to me, a second image you provided is a collision event with obj_invis_fout, it decreases the lives by 1 and uses room_goto(lvl3);

So that means every time you collide with invis fout it'll go to lvl 3, but what if you have 1 life left, and you decrease it by 1, and then you have 0 lives, and the first image I mentioned checks if you have 0 lives and goes to room lvl 1..


Seems like both codes could at some point .. confuse someone! like me xD

Yes so I believe the reason you go back to the current level is the second portion.. will run first, you know what it does, it sends you back to lvl 3, and I'm guessing that lvl 3 creates a new instance of obj_kruis, which is basically restarting the life points..

Alright so I think the solution you could try is upon collision with obj_invis,

if health > 0
health -= 1
goto room lvl 3

if health == 0
goto room lvl 1

does that make sense ?
 

TsukaYuriko

☄️
Forum Staff
Moderator
yeah i forgot about that it was kinda late yesterday when i was working on it and i just wanted it to work. i aded pictures of the "code"
Then, next time, reply in the afternoon since nights seems to make you forget to post code, while mornings make you post screenshots of code. Post code as code. Text. We can't copy and paste images into our code editors. ;)
 
C

casperk

Guest
Then, next time, reply in the afternoon since nights seems to make you forget to post code, while mornings make you post screenshots of code. Post code as code. Text. We can't copy and paste images into our code editors. ;)
i added the code in quotations in my comment because as you can see with the now provided pictures it isn't code.
 
C

casperk

Guest
Portion 1I'm a real rookie at D&D so take this with a grain of salt, but of your three images, 1 image shows that at the no more lives event 2 things happen, you check if lives are == 0, and if so then you use room_goto(lvl1); ..

Portion 2

That makes sense to me, a second image you provided is a collision event with obj_invis_fout, it decreases the lives by 1 and uses room_goto(lvl3);

So that means every time you collide with invis fout it'll go to lvl 3, but what if you have 1 life left, and you decrease it by 1, and then you have 0 lives, and the first image I mentioned checks if you have 0 lives and goes to room lvl 1..


Seems like both codes could at some point .. confuse someone! like me xD

Yes so I believe the reason you go back to the current level is the second portion.. will run first, you know what it does, it sends you back to lvl 3, and I'm guessing that lvl 3 creates a new instance of obj_kruis, which is basically restarting the life points..

Alright so I think the solution you could try is upon collision with obj_invis,

if health > 0
health -= 1
goto room lvl 3

if health == 0
goto room lvl 1

does that make sense ?
first of al i thank you for the effort you put in this to help me.
what u described to me makes sense. as you said i think that if you get send back to lvl 3 the amount of hearts reset. probably because in the create event i give it 2 hearts. but i tried what u said that could be the problem. sadly it failed and it kept sending me back to lvl 3.

edit: when i typed the reply i thought of an other option. there is also an event that happens when you start the game. so i removed the give 2 lives at the place of the create event and only gave it those 2 lives. at the beginning of the game. ones again thanks for the effort.
 
Top