Posted: 16th Jan 2003 12:10
man, i've tried so hard 2 get his thing work!!!

can someone tell me a code for gravity, and when i press shift the character jump??? i have been working for this to my game for a very very long time now...

bythe way , i use DBC (darkbasic classic)
Posted: 16th Jan 2003 14:32
try this:-

+ Code Snippet
Rem Project: gravity
Rem Created: 21/09/2002 16:04:35

Rem ***** Main Source File *****

rem Standard Setup Code
sync on : sync rate 60 : autocam off
color backdrop rgb(0,0,0) : hide mouse
set text font "arial" : set text size 18 : set text transparent

`set-up a few objects
make object cube 1, 30
make object plain 2, 500, 500
xrotate object 2, 90
position object 1, 100, 0, 100
position object 2, 0, -16, 0
position camera 0, 300, 300, 50
point camera 0, 50, 50, 0

`main loop
do
gosub display
gosub Input_check
if jmp=1 then gosub Jump_run
if (init_pos + S#)<0 then gosub end_jump
sync
loop


display:
step#=(60.0/screen fps())
text 0, 0, "Use arrow keys to control and space to Jump."
return


Input_check:
rem boring stuff
if upkey()=1 then move object 1, (5.0*step#)
if downkey()=1 then move object 1, (-5.0*step#)
if leftkey()=1 then yrotate object 1,(object angle y(1))-(5.0*step#)
if rightkey()=1 then yrotate object 1,(object angle y(1))+(5.0*step#)
if spacekey()=1 and jmp=0 then jmp=1 : init_pos=object position y(1)
if jmp=0 then position object 1, object position x(1), floor#, object position z(1)
return

Jump_run:
rem important stuff
if jmp=1 then inc time#, (1.0*step#)
S#=(12.0*time#)+(0.5)*(-0.6)*(time#^2.0)
position object 1, object position x(1), init_pos + S#, object position z(1)
return


end_jump:
jmp=0
time#=0.0
return
Posted: 25th Jan 2003 17:51
I have a code for gravity on my website (below)
just adjust it for your needs.
Posted: 25th Jan 2003 18:26
On Earth objects accelerate at around 1m/s/s I think

Its a little closer to 9.81ms^-2 , maybe you were thinking of the moon?