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 / Jumping

Author
Message
zapakitul
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: In my world
Posted: 18th Mar 2009 13:29 Edited at: 18th Mar 2009 13:30
I am trying to make an object jump if the SpaceKey is pressed. My idea was the following:

This is my implementation:

It jumps, but only once. Now i do not understand what i am doing wrong here. Any hints?
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 18th Mar 2009 13:37
Quote: "Now i do not understand what i am doing wrong here. Any hints?"


Follow through the logic of the code: 'jumptimer = jumptimer - 1;', this only gets called when BOTH the spacekey is held and 'jumptimer' is more than 2, 'jumptimer' only gets reset to 60 if it's below 0, but it can never get below 0 due to the first bit.

Also, ideally your object would have an X/Y/Z velocity vector and if the object is on the ground and you press space then you'd add some value to your Y velocity. Then every frame you add the velocity to your position and also decrement the Y velocity based on gravity and maybe lower the other ones due to drag. Of course all these computations should be multiplied by some elapsed time scalar so it will run the same on all machines.

zapakitul
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: In my world
Posted: 31st Mar 2009 15:28
Thanks for the help Dark Coder. I have been looking on Timer Based Movement and i will integrated it as soon as i finish with the basic mechanics. Anyway, my level is a 3D Object (.X) which i load. I use sparky for the collision. My jumping code would be something like this:

Now, the problem i am facing is that it jumps on walls, and that is something i don't quite like, and i can't find a way not to make it do that. What i did to fix the bug for a level was i limited the place where the player could jump, like if it was near the wall jump wouldn't work there. For the time it worked but the problem is i started adding new levels and the problem is some of them are to complex and i can't waist time by "hard coding" every space where a player can jump. So my question to you guys is, any idea on how to change my jump routine so that the player won't get to "slide jump the wall"(and the ceiling while where at it). Thanks in advance, and i do not need code, just ideas, thank you.
zapakitul
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: In my world
Posted: 31st Mar 2009 22:02
Solved the problem by exporting the walls separately. But now.. well does anyone have a solution for my jump code? I can't fix the following bug: If SPACE is pressed multiple times (even thought the player is in the air) he continues to "jump" like it's height is increasing! Any ideas?
silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 31st Mar 2009 23:31
Check my Code:
It works, but poorly commented
When you ve got questions, ask...

http://forum.thegamecreators.com/?m=forum_view&t=147146&b=6
zapakitul
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: In my world
Posted: 12th May 2009 12:41 Edited at: 12th May 2009 16:51
Well it's been a while and i still didn't manage to fix my jump code. I have almost everything completed except the jump routine that bugs me allot. Here's the problem i am facing.

1st: If the jump hasn't been completed, and the char is still in the air, the balls "flickrs" allot.
2nd: If i am close to a wall, i can tap jump rapidly and jump on it... same goes for the ceiling.

This is my jump routine:

gravity = -0.28f;
floatj = 0;
jSpeed = 1.4f;

This thing is bugging me for quite a while now, and i can't seem to be able to solve it :
zapakitul
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: In my world
Posted: 12th May 2009 16:52 Edited at: 12th May 2009 16:53
Whoohoo fixed! Here's my code:

Login to post a reply

Server time is: 2024-10-01 01:19:19
Your offset time is: 2024-10-01 01:19:19