Hello!
I wrote a quick example:
rem Jump example
rem TheComet
rem setup screen
sync on
sync rate 60
backdrop on
color backdrop rgb(128,128,128)
fog on
fog distance 2000
fog color rgb(128,128,128)
hide mouse
rem generate a grass image
create bitmap 1,256,256
ink rgb(150,150,150),0
box 0,0,255,255
for t=0 to 10000
g=rnd(50)+30
sx=rnd(255)
sy=rnd(255)
if rnd(1)=0 then ex=sx:ey=rnd(40)-20+sy else ey=sy:ex=rnd(40)-20+sx
ink rgb(0,g,0),0
line sx,sy,ex,ey
next t
get image 1,0,0,256,256
delete bitmap 1
rem generate a brick image
create bitmap 1,32,16
for t=1 to 1000
r=rnd(50)+100
ink rgb(r,r,r),0
circle rnd(32),rnd(16),3
next t
ink rgb(60,60,60),0
line 0,0,31,0:line 31,0,31,15:line 31,15,0,15:line 0,15,0,0
ink rgb(90,90,90),0
line 1,1,30,0:line 30,1,30,14:line 30,14,1,14:line 1,14,1,1
ink rgb(130,130,130),0
line 2,2,29,2:line 29,2,29,13:line 29,13,2,13:line 2,13,2,2
blur bitmap 1,5
get image 2,0,0,32,16
delete bitmap 1
rem create a matrix
make matrix 1,10000,10000,20,20
prepare matrix texture 1,1,2,2
fill matrix 1,0,1
randomize matrix 1,125
rem make a player
make object cylinder 1,10
position object 1,5000,0,5000
color object 1,rgb(234,162,28)
make object collision box 1,-5,-5,-5,5,5,5,0
rem make some decorative objects
for t=2 to 25
make object box t,80,320,80
x#=rnd(10000):z#=rnd(10000):y#=get ground height(1,x#,z#)+150
position object t,x#,y#,z#
texture object t,2
scale object texture t,10,40
make object collision box t,-40,-160,-40,40,160,40,0
next t
rem main loop
do
rem control camera
set camera to follow x#,y#,z#,object angle y(1),70,y#+20,10,1
point camera x#,y#,z#
rem get input
if upkey()=1 then move object 1,2
if downkey()=1 then move object 1,-2
if leftkey()=1 then yrotate object 1,wrapvalue(object angle y(1)-2)
if rightkey()=1 then yrotate object 1,wrapvalue(object angle y(1)+2)
if spacekey()=1 and grav#=0.0 then grav#=2.0
rem LOOK AT THIS ---------------------------------------------------------------------------------
rem get player positions
x#=object position x(1)
y#=object position y(1)
z#=object position z(1)
rem add gravity
dec grav#,0.1
inc y#,grav#
rem collision with ground
g#=get ground height(1,x#,z#)+5
if y#<g# then y#=g#:grav#=0.0
rem collision with decorative objects
if object collision(1,0)
dec x#,get object collision x()
dec y#,get object collision y()
dec z#,get object collision z()
grav#=0.0
endif
rem update player positions
position object 1,x#,y#,z#
rem ------------------------------------------------------------------------------------------------
rem refresh screen
sync
rem end of main loop
loop
The part that you are interested in is this:
rem get player positions
x#=object position x(1)
y#=object position y(1)
z#=object position z(1)
rem add gravity
dec grav#,0.1
inc y#,grav#
rem collision with ground
g#=get ground height(1,x#,z#)+5
if y#<g# then y#=g#:grav#=0.0
rem collision with decorative objects
if object collision(1,0)
dec x#,get object collision x()
dec y#,get object collision y()
dec z#,get object collision z()
grav#=0.0
endif
rem update player positions
position object 1,x#,y#,z#
Just study the code. You will get the hang of it.
TheComet
Peachy, and the Chaos of the Gems
