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 Professional Discussion / This might annoy alot of people but how do u make a player jump?

Author
Message
Altedor
22
Years of Service
User Offline
Joined: 6th Nov 2003
Location: France
Posted: 22nd Nov 2003 18:11
Soz. probably everybodies asked this. Maybe it shoudl be in CodeBase???
So how do you do it? How do you make a player jump and then return to the ground with gravity.

Jack Borhwick
Mussi
23
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 22nd Nov 2003 18:49
what's the genre? 3rd person jump code wouldn't be the same as an FPS jump code

Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 80GB HD 7200rmp U133, Geforce 4 Ti4400 128mb ddr sdram
PiratSS
23
Years of Service
User Offline
Joined: 18th Oct 2002
Location:
Posted: 22nd Nov 2003 18:59
Simple,

if spacekey()=1 and jump=0 then jump=1
if jump=1 and jmp<50 then jmp=jmp+1
if jump=1 and jmp>=50 then jump=2
if jump=2 and jmp>1 then jmp=jmp-1
if jump=2 and jmp<=1 then jump=0
position object 1,x#,y#+sin(jmp)*20,z


Have fun!

"Talk doesn't cook rice." -Chinese proverb
Mussi
23
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 22nd Nov 2003 19:06
wouldn't that mean that you would go through the ground if the ground heigt infront of you is higher then the groundheigt your standing on?

Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 80GB HD 7200rmp U133, Geforce 4 Ti4400 128mb ddr sdram
Mussi
23
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 22nd Nov 2003 19:37
hmmm.... if I press the spacebar while I'm falling down from a previous jump I jump up agian :/, why is that?

Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 80GB HD 7200rmp U133, Geforce 4 Ti4400 128mb ddr sdram
hmm
22
Years of Service
User Offline
Joined: 11th Oct 2003
Location:
Posted: 22nd Nov 2003 19:51
You should use a 'gravity' variable (g#).

if y#<=get ground height(1,x#,z#)
y#=get ground height(1,x#,z#)
g#=0
else
g#=g#-0.1 : `(change if need be)
endif
y#=y#+g#


When you're above the ground you accelerate downwards. When you hit the ground you stop. To jump:

if y#<=get ground height(1,x#,z#)
if spacekey()=1 then g#=2
endif


coincidence? how about pure cosmic convergence!
Altedor
22
Years of Service
User Offline
Joined: 6th Nov 2003
Location: France
Posted: 22nd Nov 2003 19:54
The code seems to work but my player will no longer walk why is this?

So did u do it? Nope. God Mr. Nobody's probably the cleverest man in the world. He could make millions!
Altedor
22
Years of Service
User Offline
Joined: 6th Nov 2003
Location: France
Posted: 22nd Nov 2003 19:56
The genre is 3rd Person.

So did u do it? Nope. God Mr. Nobody's probably the cleverest man in the world. He could make millions!

Login to post a reply

Server time is: 2026-07-26 15:30:16
Your offset time is: 2026-07-26 15:30:16