Posted: 26th Nov 2003 17:48
Still cut out code. Lets try this,
Dugzilla
sync
center text screen width()/2,screen height()/2,"LOADING"
sync
sync rate 100
sync on
color backdrop 0
set ambient light 100
set camera range 0,1,5000
````````````````````````````````````````````````````````````````````
load object "land.x",1
position object 1,0,0,0
yrotate object 1,180
````````````````````````````````````````````````````````````````````
load object "colonel z\colz.x",2
rotate object 2,-90,0,0
position object 2,0,0,-2000
set object speed 2,20000
scale object 2,75,75,75
fix object pivot 2
````````````````````````````````````````````````````````````````````
do
set cursor 1,1
print "Fps=",screen fps()
gosub player_control
gosub camera_and_collision
gosub collision_and_ramp
sync
loop
````````````````````````````````````````````````````````````````````
player_control:
if spacekey()=1 then position object 2,0,0,0
if upkey()=1 then move object 2,+7 : loop object 2,26700,32100
if upkey()=0 then loop object 2,1,9000
if downkey()=1 then move object 2,-7
if rightkey()=1
yrotate object 2,wrapvalue(object angle y(2)+5)
loop object 2,26700,32100
endif
if leftkey()=1
yrotate object 2,wrapvalue(object angle y(2)-5)
loop object 2,26700,32100
endif
return
````````````````````````````````````````````````````````````````````
collision_and_ramp:
radius#=30.0
checks=8
if checks<8 then checks=8
if checks>8 then checks=8
angwidth=360/checks
dim ang#(checks-1,2)
dim sort#(checks-1,2)
for x=0 to checks-1
chx#=newxvalue(x#,x*angwidth,100)
chz#=newzvalue(z#,x*angwidth,100)
ang#(x,1)=intersect object(1,x#,y#+50,z#,chx#,y#,chz#)
if ang#(x,1)=0 then ang#(x,1)=999999
ang#(x,2)=x*angwidth
sort#(x,1)=ang#(x,1)
sort#(x,2)=ang#(x,2)
next x
for x=0 to checks-2
for y=x+1 to checks-1
if ang#(x,1)>ang#(y,1)
temp#=ang#(x,1)
temp2#=ang#(x,2)
ang#(x,1)=ang#(y,1)
ang#(x,2)=ang#(y,2)
ang#(y,1)=temp#
ang#(y,2)=temp2#
endif
next x
next y
print "Player Distance to Wall=",ang#(0,1)
prev=wrapvalue(ang#(0,2)-90)/angwidth
nxt=wrapvalue(ang#(0,2)+90)/angwidth
newd#=radius#-ang#(0,1)
newa#=wrapvalue(ang#(0,2)-180)
newd1#=radius#-sort#(prev,1)
newa1#=wrapvalue(sort#(prev,2)-180)
newd2#=radius#-sort#(nxt,1)
newa2#=wrapvalue(sort#(nxt,2)-180)
if ang#(0,1)<radius# and ang#(0,1)>0.0
repx#=newxvalue(x#,newa#,newd#)
repz#=newzvalue(z#,newa#,newd#)
position object 2,repx#,y#,repz#
endif
x#=object position x(2)
z#=object position z(2)
if sort#(prev,1)<radius# and sort#(prev,1)>0.0
repx1#=newxvalue(x#,newa1#,newd1#)
repz1#=newzvalue(z#,newa1#,newd1#)
position object 2,repx1#,y#,repz1#
endif
x#=object position x(2)
z#=object position z(2)
if sort#(nxt,1)<radius# and sort#(nxt,1)>0.0
repx2#=newxvalue(x#,newa2#,newd2#)
repz2#=newzvalue(z#,newa2#,newd2#)
position object 2,repx2#,y#,repz2#
endif
charht#=130
x#=object position x(2)
y#=object position y(2)
z#=object position z(2)
sub#=intersect object(1,x#,y#+125,z#,x#,y#-(charht#*2),z#)
ht#=(y#+charht#)-sub#
if sub#=0 then ht#=charht#
grav#=grav# -2
if y#+grav#<ht#
grav#=0.0
position object 2,x#,ht#,z#
else
ht#=y#+grav#
position object 2,x#,ht#,z#
endif
return
````````````````````````````````````````````````````````````````
camera_and_collision:
x#=object position x(2)
y#=object position y(2)
z#=object position z(2)
a#=object angle y(2)
d#=150
h#=130
s#=20
set camera to follow 0,x#,y#,z#,a#,d#,h#,s#,0
radius#=10.0
checks=4
if checks<4 then checks=4
if checks>4 then checks=4
angwidth=360/checks
dim ang#(checks-1,2)
dim sort#(checks-1,2)
cx#=camera position x()
cy#=camera position y()
cz#=camera position z()
for x=0 to checks-1
chx#=newxvalue(cx#,x*angwidth,100)
chz#=newzvalue(cz#,x*angwidth,100)
ang#(x,1)=intersect object(1,cx#,cy#+50,cz#,chx#,cy#,chz#)
if ang#(x,1)=0 then ang#(x,1)=999999
ang#(x,2)=x*angwidth
sort#(x,1)=ang#(x,1)
sort#(x,2)=ang#(x,2)
next x
for x=0 to checks-2
for y=x+1 to checks-1
if ang#(x,1)>ang#(y,1)
temp#=ang#(x,1)
temp2#=ang#(x,2)
ang#(x,1)=ang#(y,1)
ang#(x,2)=ang#(y,2)
ang#(y,1)=temp#
ang#(y,2)=temp2#
endif
next x
next y
print "Camera Distance to Wall=",ang#(0,1)
prev=wrapvalue(ang#(0,2)-90)/angwidth
nxt=wrapvalue(ang#(0,2)+90)/angwidth
newd#=radius#-ang#(0,1)
newa#=wrapvalue(ang#(0,2)-180)
newd1#=radius#-sort#(prev,1)
newa1#=wrapvalue(sort#(prev,2)-180)
newd2#=radius#-sort#(nxt,1)
newa2#=wrapvalue(sort#(nxt,2)-180)
if ang#(0,1)<radius# and ang#(0,1)>0.0
repx#=newxvalue(cx#,newa#,newd#)
repz#=newzvalue(cz#,newa#,newd#)
position camera repx#,cy#,repz#
endif
cx#=camera position x()
cz#=camera position z()
if sort#(prev,1)<radius# and sort#(prev,1)>0.0
repx1#=newxvalue(cx#,newa1#,newd1#)
repz1#=newzvalue(cz#,newa1#,newd1#)
position camera repx1#,cy#,repz1#
endif
cx#=camera position x()
cz#=camera position z()
if sort#(nxt,1)<radius# and sort#(nxt,1)>0.0
repx2#=newxvalue(cx#,newa2#,newd2#)
repz2#=newzvalue(cz#,newa2#,newd2#)
position camera repx2#,cy#,repz2#
endif
return
````````````````````````````````````````````````````````````````