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.

DarkBASIC Discussion / Gravity / Jumping problem.

Author
Message
cloneboy
19
Years of Service
User Offline
Joined: 28th Aug 2005
Location: Ontario, Canada
Posted: 14th Jan 2006 20:33
In my game, the characters can superjump. I'd like, as with almost every other game, a normal jump. Like, about as high as himself. He should land softly and at about a normal speed when dropping.

But, I also need a super jump. He should jump about 10 times higher then that, and linger in the air before he comes down. By linger, i mean that when he starts to come down, it start slowly.

On the way down, he should start slowly, then start to come down faster and faster, but I'd like a limit on how fast he can come down. I dunno how to write that into code, and I'd like to learn the commands and stuff on how to do it.
Hobgoblin Lord
19
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 14th Jan 2006 20:46
You could set up a variable like "velocity" and another called "Max velocity" when the character starts to fall incrementally increase velocity as long as it is less than max velocity. If you need a code sample i will have a little time later to put one together
cloneboy
19
Years of Service
User Offline
Joined: 28th Aug 2005
Location: Ontario, Canada
Posted: 14th Jan 2006 21:12
That'd be kool ty
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 15th Jan 2006 12:20 Edited at: 15th Jan 2006 12:21
Most ppl use a variable called "yspeed#", which is constantly added by the player's y position. and yspeed# is constantly decreased by the gravity.

Because of this, the player will
float/stand if the yspeed# = 0
go up if the yspeed# > 0
go down if the yspeed# < 0.

Because the gravity pulls the yspeed# as slow as you want, the object will speed up according to the gravity.
To limit the falling speed, simply use the condition:
if yspeed# < MaxFallSpeed# then yspeed# = MaxFallSpeed#

Note: MaxFallSpeed# has to be < 0. Because the object has to be falling before reaching the limited falling speed.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
cloneboy
19
Years of Service
User Offline
Joined: 28th Aug 2005
Location: Ontario, Canada
Posted: 15th Jan 2006 16:19
Very helpful. Thanks a lot.

Login to post a reply

Server time is: 2025-05-23 00:47:17
Your offset time is: 2025-05-23 00:47:17