S
Storm1208
Guest
Hey all! As a sort of pet project I've been attempting to recreate the game engine for the popular indie game VVVVVV within GMS 1.4. Everything has been going smoothly so far but I've had an issue for a few weeks now and I just can't seem to figure out how to resolve it.
Within my game, the player can click the space bar to flip gravity; however, the player shouldn't be able to flip gravity again until they make contact with the ground (or ceiling depending on their orientation ) For some odd reason, my code is allowing the main character to "double flip"(in other words, after flipping once, the player can flip again even if they haven't made contact with the ground yet) Below is my code that both stops the flipping from being active and allows it to be used again.
Initial Gravity Flipping:
Resetting Flip Variable and Detecting Ground Collision:
I tried running my code through GameMaker's debugger and it looks like the flip variable is being reset to 1 before it's even reached within the if statement and I'm not entirely sure why(in the debugger, flip had already been set back to 1 while the program was still in the vertical collision's while loop). I'd appreciate any help!
Within my game, the player can click the space bar to flip gravity; however, the player shouldn't be able to flip gravity again until they make contact with the ground (or ceiling depending on their orientation ) For some odd reason, my code is allowing the main character to "double flip"(in other words, after flipping once, the player can flip again even if they haven't made contact with the ground yet) Below is my code that both stops the flipping from being active and allows it to be used again.
Initial Gravity Flipping:
Code:
//Jumping
if(key_space && flip == 1)
{
flip = 0;
image_yscale = -image_yscale;
grv = -grv; //flip gravity if key pressed and on ground
}
Code:
//Vertical Collision
if(place_meeting(x,y+vsp,obj_ground)) //if we're about to collide with a ground tile
{
while(!place_meeting(x,y+sign(vsp),obj_ground))//keep moving until...
{
y += sign(vsp);
}
vsp = 0; //BAM - stop moving
flip = 1;
}