So, I downloaded it and got simple jumping working as phase one of solving your problems--
First, I deleted the code you put in Step->End Step.
I then had to make some assumptions about the world, and added the following code:
In CREATE EVENT:
zFloorOffset = 20; //I need a value to check for landing. Since the camera is floating, I'm offsetting it's own virtual floor to match.
meter = 20; //looks like 20 units is about a meter in the world (height of box.)
zGravity = 9.81 * meter / room_speed; //rate of gravity in meters converted to system units
isFreefall = false; //state boolean for being in freefall.
zSpeed = 0; //we'll use this just like h and vspeed.
zJumpHeight = 2 * meter; //max height of a jump... 1 meter
zJumpImpulse = sqrt( 2 * zGravity * zJumpHeight ); //impulse needed to overcome gravity and jump to jump height.
That all sets up the variables needed to calculate gravity and such. You see I make some literal conversions... this is so you can make changes in a human understandable way-- what is 20 units in the game world? 1 meter. If you want to know how certain factors change behavior, change one variable at a time and test it. Changing meters is a good place to play around.
Then, I added an STEP END STEP event to handle movement resolution:
//resolve z movement
if(isFreefall){ //object in freefall
zSpeed -= zGravity; //add gravity to velocity (z direction goes UP, unlike y in 2D space.)
z += zSpeed; //add velocity to position
z = max(z, zFloorOffset); //resolve for hitting the floor.
if(z == zFloorOffset){ //on the floor
isFreefall = false; //turn off freefall state
}
}
If the object is in freefall, that is, his feet aren't on the ground (freefall includes going UP as well as DOWN,) then the code applies gravity to velocity and velocity to position. It then makes sure the object can't go through the ground, and disables the state of being in freefall if it detects the ground. NOTE: we have't accounted for jumping onto things yet! Let's crawl, then we'll walk... or jump... onto thing... as it were.
Finally, I added the jump code, because my first thought when looking at your game was "well, there's your problem... can't jump if there's no jump input!"
PRESS <SPACE>
if(!isFreefall){ //can only jump when not in freefall
isFreefall = true; //freefall state ON
zSpeed = zJumpImpulse;
}
Again, we check the state of being in freefall before doing anything else. So long as the player isn't in the air, he can jump. Later we cal talk about double jumping if that matters to you.
I have your edited game file--
Edited game fileI won't host this forever-- so get it now.