Hi all!
Here's a function I made to load a heightmap into a matrix.
input "Load this file as heightmap :",filename$ : input "Load this file as texture(leave blank if you don't want to) :",tex$
make matrix 1,2000,2000,133,133 : cls
heightmap_load(filename$,1,1) : if tex$<>"" then load image tex$,1 : prepare matrix texture 1,1,1,1
sync on : do
if mouseclick()=1 then move camera 10
if mouseclick()=2 then move camera -10
yrotate camera wrapvalue(camera angle y()+mousemovex())
xrotate camera wrapvalue(camera angle x()+mousemovey())
if camera position y()<get ground height(1,camera position x(),camera position z()) then position camera camera position x(),get ground height(1,camera position x(),camera position z()),camera position z()
sync : loop
function heightmap_load(file$,matrixnum,imagenum)
load image file$,imagenum,1 : sprite imagenum,0,0,imagenum
x=SPRITE WIDTH(imagenum) : y=SPRITE height(imagenum) : delete sprite imagenum :cls : paste image imagenum,0,0
for xval=0 to x-1
for yval=0 to y-1
currentcol=POINT(xval,yval) : nowcol=(RGBR(currentcol)+RGBG(currentcol)+RGBB(currentcol))/3 : set matrix height matrixnum,xval,yval,nowcol
next yval
next xval
update matrix matrixnum : delete image 1
endfunction
Use the following images if you don't want to use your own:
grass,
and height,
[img]http://sephiroth7769.tripod.com/sitebuildercontent/sitebuilderpictures/height.bmp
[/img]
if they don't show get them here:
http://sephiroth7769.tripod.com/sitebuildercontent/sitebuilderpictures/grass.bmp
http://sephiroth7769.tripod.com/sitebuildercontent/sitebuilderpictures/height.bmp
Hope you like it
Current Project: DarkEssence, an Action/RPG style game.