Try this
REM Project: Matrix Demo
REM Created: 20/12/2004 19:09:53
REM
REM ***** Main Source File *****
REM
`************************************************************************
`* *
`* This is my landscape that I made, I used some textures from Matedit, *
`* and some from DarkBASIC. *
`* This is one of the best matrices I've made without using a matrix *
`* making program. *
`* I am a sorta newbie, so I'm sure you could make something better :) *
`* If you have any ideas on how to improve it email me at - *
`* Zotoast@hotmail.com *
`* *
`* Bugs: The water gets crappy when you go too far away from it, and *
`* one of the mountains shows a bit of grass when you go too far away *
`* from that too. Other than that, it's fine. *
`* *
`* Files Needed: "Heightmap1.bmp"(heightmap), "Land.bmp"(4 part texture)*
`* "Water.bmp"(Water Texture), "VD.x"(Skysphere), "Valley Dawn.bmp" *
`* (Skysphere texture).....5 all together! *
`* *
`************************************************************************
`Setup sync
sync on
Hide Mouse
Print "Loading Matrix Demo..."
Sync
Sync
Sync Rate 1000
`Startup Screen
Set display mode 1024,768,32
Set Text Font "Arial Black"
Set text to Bold
CLS RGB(0,0,0)
Ink RGB(0,255,0),0
Set text size 150
Center Text 512,40,"Matrix Demo"
Ink RGB(255,0,0),0
Set text size 50
Center Text 512,225,"Created Using DarkBASIC Classic"
Ink RGB(255,0,255),0
Set text size 65
Center Text 512,300,"Created By Alastair Zotos 2004"
Ink RGB(255,255,255),0
Set text size 35
Center Text 512,370,"Thanks to Kevin Picone for Heightmap Code"
Ink RGB(255,255,255),0
Set text size 45
Set Text Font "Tahoma"
Set Text to Normal
Center Text 512,700,"Press Any Key to Continue"
Wait Key
`Main Setup
backdrop on
color backdrop rgb(0,200,255)
set camera range 1,900000
fog off
fog distance 10000
fog color rgb(0,200,255)
autocam off
Hide Mouse
set ambient light 50
`arrays
dim hmap(1)
getheightbmp("heightmap1.bmp")
`===============
`Make matrix
`===============
make matrix 1,5000,5000,70,70
load bitmap "Land.bmp",1
get image 1,0,0,256,256
delete bitmap 1
prepare matrix texture 1,1,2,2
fill matrix 1,0.0,1
for x=1 to 70
for z=1 to 70
set matrix height 1,x,z,hmap(x,z)*5
next z
next x
`texture matrix
for x=1 to 69
for z=1 to 69
if hmap(x,z)>70
set matrix tile 1,x,z,2
endif
if hmap(x,z)>80
set matrix tile 1,x,z,4
endif
if hmap(x,z)>120
set matrix tile 1,x,z,3
endif
next x
next z
`normalise matrix
for z=1 to 69
for x=1 to 69
` Get matrix heights
h8#=get matrix height(1,x,z-1)
h4#=get matrix height(1,x-1,z)
h#=get matrix height(1,x,z)
h2#=get matrix height(1,x,z)
`Calculate projected angle X using heights
x1#=(x-1)*25.0 : y1#=h#
x2#=(x+0)*25.0 : y2#=h4#
dx#=x2#-x1#
dy#=y2#-y1#
ax#=atanfull(dx#,dy#)
ax#=wrapvalue(90-ax#)
`Calculate projected angle Z using heights
z1#=(z-1)*25.0 : y1#=h2#
z2#=(z+0)*25.0 : y2#=h8#
dz#=z2#-z1#
dy#=y2#-y1#
az#=atanfull(dz#,dy#)
az#=wrapvalue(90-az#)
`Make normal from projected angle
nx#=sin(ax#)
ny#=cos(ax#)
nz#=sin(az#)
`edit positions
nox#=nx#*25000
noy#=ny#*9000
noz#=nz#*1000
`Setting matrix normal for smoothness
set matrix normal 1,x,z,nox#,noy#,noz#
next x
next z
`update the matrix
update matrix 1
`===========
`Objects
`===========
`make water
waterheight#=270
load bitmap "water.bmp",2
get image 2,0,0,128,128
make object plain 1,1000,1000
xrotate object 1,90 : fix object pivot 1
position object 1,2546,waterheight#,3886
texture object 1,2
make object plain 2,1000,1000
xrotate object 2,90 : fix object pivot 2
position object 2,2546,waterheight#+10,3886
texture object 2,2
ghost object on 2
`create sky
load image "valley dawn 2.bmp",2
load object "vd.x",4
scale object 4,700,300,700
position object 4,0,-7000,0
texture object 4,2
`=========
`Other
`=========
`variables
camspeed#=10
`syncronise screen
sync
sync
`===============
`MAIN LOOP
`===============
Do
`Fix mouse pointer
position mouse 512,384
`===============
`Move Camera
`===============
camf#=0
camx#=wrapvalue(camx#-mousemovey()*0.4)
camy#=wrapvalue(camy#+mousemovex()*0.4)
acamx#=curveangle(camx#,acamx#,2.5)
acamy#=curveangle(camy#,acamy#,2.5)
rotate camera acamx#,acamy#,0
if mouseclick()=1 then camf#=camf#+camspeed#
if mouseclick()=2 then camf#=camf#-camspeed#
if controlkey()=1 then camf#=camf#-camspeed#
if camf#<>0 then move camera camf#
`get camera positions
x#=camera position x()
y#=camera position y()
z#=camera position z()
`Position Camera
yg#=get ground height(1,x#,z#)+2
if y#<yg#
y#=yg#
else
y#=y#
endif
if y#<waterheight#+20
if x#<3000 and x#>2000
if z#<4200 and z#>3200
y#=waterheight#+20
endif
endif
endif
`position camera
position camera x#,y#,z#
`========
`Extras
`========
set mipmap mode 1
`=========
`Water
`==========
`animate water
wt#=wrapvalue(wt#-0.3)
yrotate object 2,wt#
scroll object texture 1,0.0005,0.0005
scroll object texture 2,0.0,0.0005
`=========
`Light
`=========
position light 0,nx#,ny#,nz#
`===========
`End Loop
`===========
`Update screen
sync
`End Loop
loop
`===============
`FUNCTIONS
`===============
`Heightmap
`=================
`get the heightmap
function getheightbmp(file$)
`open file
open to read 1,file$
`--------------------
`decode
read byte 1,notusefull
read byte 1,notusefull
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
`--------------------
`Get Bitmap Width
read long 1,BmpWidth
`Get Bitmap Height
read long 1,BmpHeight
`--------------------
read word 1,notusefull
`--------------------
`Get BitDepth
read word 1,BitDepth
`--------------------
`The info contained here is not usefull.
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
`--------------------
`error check only if bitdepth=24
if BitDepth=24
ypos=BmpHeight
`Calculate If bmp required Padding
bmpwidth#=bmpwidth
evenwidth1#=(BmpWidth#*3)/4
evenwidth2=(BmpWidth*3)/4
padlen=0
if evenwidth1#<>evenwidth2
evenwidth1#=evenwidth1#-evenwidth2
padlen=4-(evenwidth1#*4)
endif
`-------------------------------------------
`create the hmap array
dim hmap(bmpwidth,bmpheight)
`-------------------------------------------
`Get color info
For Ylp=1 to BmpHeight
for Xlp=1 to Bmpwidth
`Read color values
read byte 1,blue
read byte 1,Green
read byte 1,red
`enter color info into height array
hmap(xlp,ypos)=(blue+green+red)/3
next Xlp
dec Ypos
`Padding
if padlen<>0
for padlp=1 to padlen
read byte 1,padbyte
next padlp
endif
next Ylp
endif
`close the file
close file 1
`end current function
endfunction
"Well, if he dies, it'll teach him not to do it again." - Me