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.

Newcomers DBPro Corner / how do i make jumping?

Author
Message
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 28th Mar 2005 23:14
Hi

me and KLU 007 working on a game. We use NGC. So we have the gravity. We can control an object around in levels. But now we need to make the object jump if you hit the spacekey.
But we can`t figure out how to do it right.
So how can we make our object jump if you press the spacekey?

Thanks


PanzerGames website :
http://www.panzergames.tekhawk.com
DK_
20
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 29th Mar 2005 03:25 Edited at: 29th Mar 2005 03:25
Here is what I use to jump.



Then at the line where you reposition your player down due to gravity instead of:
position camera 0,camer position x(0),camera position y(0)-gravity#,camera position z(0)

use this:
position camera 0,camera position x(0),camera position y(0)-(gravity#-jump#),camera position z(0)

I don't know what NGC is, but if it does gravity for you than add this in the main loop:
position camera 0,camera position x(0),camera position y(0)+jump#,camera position z(0)

if your gravity is higher than the value I used make sure to change line #19 where I commented it.

Freddy 007
19
Years of Service
User Offline
Joined: 30th Nov 2004
Location: Denmark
Posted: 30th Mar 2005 23:13
Thanks, but I don't think that will work with the NGC gravity.

Baggers
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Yonder over dem dere hills
Posted: 31st Mar 2005 09:01
in basic terms if you are on the floor, and space is pressed, apply a positive verticle force....however i dont know how this is done in newton.
bibz1st
21
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 2nd Apr 2005 22:39
if you had GRAVITY# = 2.0
in your game loop do this...
[/code]
DO

IF SPACEKEY() = 1 AND jump = 0
Gravity# = -4.0
SetObjGravityPRO( PlayerObjNo, Gravity# )
jump=1
ENDIF

IF Gravity# < 1.9
inc Gravity#, 0.1
SetObjGravityPRO( PlayerObjNo, Gravity# )
ENDIF

IF Gravity# >= 2.0 and collision > 0 then jump=0

LOOP
[code]
where I have written the word collision is where you must put your variable for checking if your jumping object is actually on something that it can jump off
can you understand that?
DC Programmer
19
Years of Service
User Offline
Joined: 1st Apr 2005
Location:
Posted: 5th Apr 2005 06:55
Hello check out the incredible jumping object!!!

Make object cube 1,5 : Position object 1,-3,-15,0 : Color object 1,rgb(255,255,0)
Make object cube 2,5 : Position object 2,3,-15,0 : Color object 2,rgb(0,255,0)
Make object cube 3,50 : Position object 3,0,-50,0
p=0
p2=0
gravity=1
Do
If leftkey()=1 then move object left 2,0.5 : left=1 : right=0 : up=0 : down=0
If rightkey()=1 then move object right 2,0.5 : left=0 : right=1 : up=0 : down=0
If upkey()=1 then move object 2,object angle z(2)+0.5 : left=0 : right=0 : up=1 : down=0
If downkey()=1 then move object 2,object angle z(2)-0.5 : left=0 : right=0 : up=0 : down=1

If gravity=1 then move object down 1,5
If object collision(1,3) then move object up 1,5

If gravity=1 then move object down 2,5
If object collision(2,3) then move object up 2,5

If spacekey()=1 then move object up 2,5 : jump=1

If object collision(1,2) and left=1 then move object left 1,1
If object collision(1,2) and right=1 then move object right 1,1
If object collision(1,2) and up=1 then move object 1,object angle z(1)+1
If object collision(1,2) and down=1 then move object 1,object angle z(1)-1
Loop
[/code
There is a only 1 problem when you jump and hold down the spacekey you float.. but i think i did it kind of right though XD

D.C

Login to post a reply

Server time is: 2024-11-12 01:15:53
Your offset time is: 2024-11-12 01:15:53