rem Make a simple scene
make matrix 1,10000.0,10000.0,50,50
load bitmap "grass16.bmp",1
get image 1,0,0,256,256
delete bitmap 1
prepare matrix texture 1,1,2,2
randomize matrix 1,50.0
set matrix height 1,12,12,100
set matrix height 1,13,13,100
set matrix height 1,12,13,100
update matrix 1
color backdrop 255
fog on
fog color 128
fog distance 2000
rem Create character to follow
make object sphere 1,100
rem Set variables for character position
x#=500
z#=500
rem Create fence
for f=3 to 75
load object "fence.x",f
position object f,(f*125),20,500
load image "Wood01.jpg",3
texture object f,3
next f
rem Activate manual sync
sync on
rem Begin loop
do
rem Control camera with arrow keys
if upkey()=1 then x#=newxvalue(x#,a#,15) : z#=newzvalue(z#,a#,15)
if downkey()=1 then x#=newxvalue(x#,a#,-15) : z#=newzvalue(z#,a#,-15)
if leftkey()=1 then a#=wrapvalue(a#-10.0)
if rightkey()=1 then a#=wrapvalue(a#+10.0)
rem Update character
y#=get ground height(1,x#,z#)+50.0
position object 1,x#,y#,z#
yrotate object 1,a#
rem Position camera to the back of the character
cx#=newxvalue(x#,wrapvalue(a#+180),300)
cz#=newzvalue(z#,wrapvalue(a#+180),300)
cy#=get ground height(1,cx#,cz#)+225.0
position camera cx#,cy#,cz#
rem Point camera at object
point camera x#,y#,z#
rem Syncronise
sync
rem End loop
loop
I could use help with this code, it is modified from one of the examples in DB that I am experimenting with. Currently it loads the fence model and copies it across one side of the matrix. First, there is a strange glitch when the program is setting down the fence. The player sphere and the fence model blink on the screen and movement is impossible for a while. Any idea of how I can fix this?
Second, I would like the fence to enclose the matrix (congruent with the side it currently resides upon). Is there a way?
Any help is much appreciated.