Posted: 23rd Apr 2003 01:39
rem Calculate four X+Z coordinates for each corner
foot#=110
ta#=wrapvalue(a#-45)
frontleftx#=newxvalue(x#,ta#,foot#) : frontleftz#=newzvalue(z#,ta#,foot#)
ta#=wrapvalue(a#+45)
frontrightx#=newxvalue(x#,ta#,foot#) : frontrightz#=newzvalue(z#,ta#,foot#)
ta#=wrapvalue(a#+225)
backleftx#=newxvalue(x#,ta#,foot#) : backleftz#=newzvalue(z#,ta#,foot#)
ta#=wrapvalue(a#+135)
backrightx#=newxvalue(x#,ta#,foot#) : backrightz#=newzvalue(z#,ta#,foot#)
rem Calculate degree of tilting from corner heights
frontlefth#=get ground height(1,frontleftx#,frontleftz#)
frontrighth#=get ground height(1,frontrightx#,frontrightz#)
backlefth#=get ground height(1,backleftx#,backleftz#)
backrighth#=get ground height(1,backrightx#,backrightz#)
across#=((frontrighth#-frontlefth#)+(backrighth#-backlefth#))/2.0
length#=((backlefth#-frontlefth#)+(backrighth#-frontrighth#))/2.0
xrotate object 1,wrapvalue(length#/4.0)
zrotate object 1,wrapvalue(across#/4.0)
x#=newxvalue(x#,a#,s#)
z#=newzvalue(z#,a#,s#)
h#=get ground height(1,x#,z#)
position object 1,x#,h#,z#
yrotate object 1,a#
if upkey()=1 and s#<8 then s#=s#+1
if downkey()=1 and s#>-8 then s#=s#-1
if leftkey()=1 then a#=wrapvalue(a#-4)
if rightkey()=1 then a#=wrapvalue(a#+4)