• 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!

If statements

N

NymmBo

Guest
I'm trying to make a puzzle where you have to hit these signs in a specific order using variables hits and last_hit. As you can see by the numbers in the game screen both conditionals are true but it doesnt actually spawn the health object, only the sword?
1597755800252.png
 

Nidoking

Member
As you can see by the numbers in the game screen
Can I? I have no idea what I'm looking at, but I don't see any numbers.

I assume there's something you left out, because hits = 1 when sign_index == 1, and last_hit = sign_index, so how can last_hit == 3 if sign_index == 1?
 

curato

Member
I would put a show_debug_message in above the if statement. See what last_hit actually equals that may let you know what the mistake is.
 
N

NymmBo

Guest
Sorry, I should've explained better. each sign or colourful square has a number assigned to it (sign_index) from 1-4 left-right. there are two numbers haphazardly stuck on screen, a 1 showing the number of hits and the 3 showing the sign index. If the hits are equal to one and the sign index = 3 it should spawn a health pickup, which, since both are true, it should have done so. But it hasnt

p.s. sorry if i just mansplained that
 
N

NymmBo

Guest
New problem, I've tried it again with a debug message and it works, except it resets the hits after the correct sign it hits. Apart from this collision event there's only a creation event initialising last_hit and hits to 0. Any ideas?
1597767745174.png
 

Roldy

Member
It is a bit hard to tell from what you have posted but I suspect that hits and last_hit are instance variables of your obj_puzszle_sign.

Meaning each sign is storing its own copy of 'hits' and 'last_hit.' This probably not what you intend.
 
N

NymmBo

Guest
It is a bit hard to tell from what you have posted but I suspect that hits and last_hit are instance variables of your obj_puzszle_sign.

Meaning each sign is storing its own copy of 'hits' and 'last_hit.' This probably not what you intend.
You were completely right, I turned it into a global variable and it seems to work perfect. Thanks a bunch :)
 
Top