Im using a heightmap to create a formed matrix, my character entity moves by collecting the matrix height and that position and positioning itself above the matrix. The problem is i changed my heightmap to raise everything up by 100 units, but my character still stays at the original matrix hieght of 0 rather than raising itself above it.
My code is:
Sync On
Sync Rate 30
setupMatrix("textureterrain1.bmp",2000,2000)
textureMatrix("textureground1.JPG")
backdrop(50,10,10)
addObject("texturehouse1.x",200,102,200,2000,1200,2000,0,20,0)
addObject("texturehouse1.x",200,102,500,2000,1200,2000,0,130,0)
Rem Make player pawn
Make object cone 10,25
position object 10,100,102,100
Rem Main loop
Do
set cursor 0,0
print screen fps()
Rem Store Object angle
AngleY# = object angle Y(10)
Rem Control input for camera
If Upkey()=1
XTest# = Newxvalue(X#,AngleY#,20)
ZTest# = Newzvalue(Z#,AngleY#,20)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
Move object 10,10
Endif
Endif
If Downkey()=1
XTest# = Newxvalue(X#,AngleY#,20)
ZTest# = Newzvalue(Z#,AngleY#,20)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
Move object 10,-10
Endif
Endif
If Leftkey()=1 then Yrotate object 10,Wrapvalue(AngleY#-5)
If Rightkey()=1 then Yrotate object 10,Wrapvalue(AngleY#+5)
X# = Object position x(10)
Z# = Object position z(10)
Y# = Get Ground Height(1,X#,Z#)
Position object 10,X#,Y#+12.5,Z#
CameraZ# = Newzvalue(Z#,AngleY#-180,100)
CameraX# = Newxvalue(X#,AngleY#-180,100)
CameraY# = Get Ground Height(1,CameraX#,CameraZ#)
Position camera CameraX#,CameraY#+50,CameraZ#
Point camera X#,Y#+25,Z#
Rem Refresh Screen
Sync
Loop
Can someone tell me what I am doing wrong?
Thanks.
[EDIT]
and here are the functions if they are important:
function setupMatrix(file$,xsize,zsize)
load bitmap file$,1
width2=bitmap width(1)
height2=bitmap height(1)
global width = width2
global height = height2
Rem make matrix
Make matrix 1,xsize,zsize,bitmap width(1),bitmap height(1)
`Extract height data and set matrix heights
set current bitmap 1
for x=0 to width-2
for z=0 to height-2
for xpixel = x to x+1
for zpixel = z to z+1
height# = height#+rgbr(point(xpixel,zpixel))
next zpixel
next xpixel
height#=height#/2
set matrix height 1,x,z,height#
next z
next x
delete bitmap 1
update matrix 1
endfunction
function textureMatrix(file$)
load image file$,1
prepare matrix texture 1,1,1,1
fill matrix 1,0,1
for x=0 to width-1
for z=0 to width-1
h=get ground height(1,x,z)
if h >= 0 then set matrix tile 1,x,z,1
next z
next x
endfunction
function backdrop(r,g,b)
backdrop on
color backdrop rgb(r,g,b)
endfunction
function addObject(file$,x,y,z,s,t,u,d,e,f)
counter=1
for a=1 to 100000
if object exist(a)=1 then inc counter
next a
load object file$,counter
scale object counter,s,t,u
xrotate object counter,d
yrotate object counter,e
zrotate object counter,f
position object counter,x,y,z
endfunction