Posted: 21st Mar 2004 16:53
Hey,
Well i got a bit bored this morning, got my physics books out and wrote some simple code for projectile physics.

2D:
+ Code Snippet
sync on
sync rate 60
dim grav#(1) : grav#(1)=10
dim hu(1) : hu(1)=10
dim vu(1) : vu(1)=0
dim height(1) : height(1)=100
dim time(1) :time(1)=10

load image "ball.bmp",1
cls



do
cls
set cursor 0,0
print hu(1)

if upkey()=1
hu(1)=hu(1)+1
wait 40
endif

if downkey()=1
hu(1)=hu(1)-1
wait 40
endif

if spacekey()=1
for time = 0 to time(1)
sh=(hu(1)*time)+50
sv=(0.5*grav#(1))*(time*time)
cls
sprite 1,sh,sv,1
sync
wait 40
next time
cls
endif

sync
loop



3D:
+ Code Snippet
sync on
sync rate 30

dim grav#(1) : grav#(1)=-0.1
dim hu(1) : hu(1)=100
dim vu(1) : vu(1)=0
dim time(1) :time(1)=50

make matrix 1,10000,10000,20,20
make object sphere 1,10

position camera -200,100,-10
point camera 0,0,0



oldtime$=get time$()
do


for time = 0 to time(1)
sv=(0.5*grav#(1))*(time*time)
sh=hu(1)*time
if sv+100>get ground height(1,object position x(1),object position y(1))
position camera -200,100,sh-10
position object 1,0,sv+100,sh
endif
sync
wait 40
next time


sync
loop

also in source box
There you go

Chaos