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
MrDuskling
13
Years of Service
User Offline
Joined: 30th Dec 2010
Location:
Posted: 13th Jan 2011 03:14
Hey.
How am i to go about making my character jump? im not really worried about collisons right now, but how do i change to Y coordinate of the sprite and then put it back down to the original? my game is very simple, walls come at you and you have to jump over them, but i cant figure out how to jump!
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 13th Jan 2011 15:41
Probably the easiest way to program that is using the basic parabola curve. You have a jump value starting off at (lets just say) +3. Each time your Y value is altered then decrease the jump value by -1. Stop jumping when it reaches -3 and you've covered a full jump curve.

The jump value goes through: +3, +2, +1, 0, -1, -2, -3

Warning! May contain Nuts!
Cetobasilius
14
Years of Service
User Offline
Joined: 29th Dec 2009
Location: Mexico
Posted: 14th Jan 2011 14:20
try to think as in real life, you have gravity. so every loop, you must have something moving your sprite down, unless its touching ground. suppose ground is 0. your sprite is at zero and cannot go underground. now, if it were to somehow leave 0(ground) there must be gravity, something that subtracts height every loop. now lets say gravity is 5. so, when your player jumps, you add some value to your vertical velocity, lets say 20, before adding this, it was 0, you had no velocity upwards or downwards. now, by adding velocityy we take off the ground, so now we are at 20, not at zero, but since there is gravity, you have to subtract it from your velocity, so your final position is 15. so then you advance 15 but - 5 of gravity, is 10, you are now at height 25, then your velocity decreases to 10, you now are at 35 then velocity decreases to 5, and you reach your max height, which will be 40. after that, your velocity becomes negative, which makes your sprite fall down until it reaches zero. some pseudocode example:



try it. i know it will work

hi

Login to post a reply

Server time is: 2024-11-19 14:42:31
Your offset time is: 2024-11-19 14:42:31