So I've set up a minigame to run like this. Several objects fly at the player, who must click on them to make them stop moving.
Once all the objects are hit, a rep_exec variable makes the player move to the next room. If the player is hit, they move to a
"game over" screen. The problem is, if the player is hit while they are about to move to the next room, an error occurs where both can't be executed at once, of course. What I want to know is, besides making the objects disappear instantly when hit, is there a way to avoid this error?
Cheers, Surplus
The error you're getting is because your code allows both conditions (win & lose) to be true in the same frame.
You can avoid this by not calling player.ChangeRoom() directly when the win or lose condition is met:
// in repeatedly_execute (pseudo code)
int next_room = 0;
if (player loses) next_room = 3;
if (player wins) next_room = 4; // winning takes precedence
if (next_room) player.ChangeRoom(next_room);
That way you can't end up with two room changes in the queue.
And I thought I could get out of some extra work by not setting up two separate variables for the actions... Oh well.
Thanks for the help, Khris!
Wait, how are you setting up two separate variables? My code doesn't.