Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Simple 2D Gravity and Jumping

Author
Message
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 13th Aug 2010 23:55
You guys may recognize this program from my "simple 2D gravity" thread....well i have another bug.

The gravity system runs fine and now im starting on a function handling the input for movement and eventually aiming and shooting. but for some reason the function is never entered in the program. heres my code:



any ideas? also when i try and use breakpoints they become hollwed out and when i mouse over them i get a caption about the source code being different from the original......whats that about?


Cetobasilius
14
Years of Service
User Offline
Joined: 29th Dec 2009
Location: Mexico
Posted: 14th Aug 2010 13:58
because input() is only checked when Player1.Collision[2] is not 0. i would suggest you check input always, and make some state variables, like PlayerIsOnGround or PlayerIsOnAir, and then you can move the player using these...

hi
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 14th Aug 2010 22:14 Edited at: 14th Aug 2010 22:31
thats what Collision[2] is. it checks if the player is on the ground.....and the idea is the player cant jump if they already in the air. i guess i should move that function to outside the if and have a check for the player being on the ground inside the jump routine of the function

but still that doesnt explain the problem

edit:

ok i figured it out. the problem was the program would go into input, see that the player was jumping, and change the jumpvalue to 5 (like it was supposed to). but then back in the main loop it would go to the "handle gravity" section before the "move player based on jump speed section". so what was happening was the gravity checking section was saying "the player is on the ground still, so we change his jumpspeed back to zero" before he was able to leave the ground


Login to post a reply

Server time is: 2024-07-02 08:56:28
Your offset time is: 2024-07-02 08:56:28