Hi,
I noticed several things that needed revision in your code. First off, object positions are recorded as float variables. Yours included integers, which are not as accurate as you will need. Also, you don't need to check for collision to establish a Y position of your object when using a matrix. You had not set a SYNC RATE for the game. By not doing this, the program will run as fast as possible on the host computer. It was literally zipping around so fast I could hardly see anything. Another thing worth noting, is that you only had the matrix setup for 11 tiles across and down. Perhaps you wanted it to look like that, but it made for huge hunks of real estate. I made it 50 X 50, which IMO looks better.
To help you out, I revised your code so that it shows you what I am talking about. Hopefully you can learn from it. I created my own image as I didn't have the one you are using. I randomly tiled it, but this is only to show you how you can do it.
sync on : sync rate 60
hide mouse
`Textures
`load image "textures/grass.png",1
rem make image 1
ink rgb(0,200,0),0 : box 0,0,64,64
ink rgb(0,100,0),0 : box 64,0,128,64
ink rgb(142,88,60),0 : box 0,64,64,128
ink rgb(242,173,11),0 : box 64,64,128,128
get image 1,0,0,128,128
`Ground
make matrix 1,10000,10000,50,50
prepare matrix texture 1,1,2,2
rem randomly place tiles
for z = 0 to 49
for x = 0 to 49
set matrix tile 1,x,z,rnd(3) + 1
next x
next z
rem make peaks and valleys in the matrix
randomize matrix 1,125.0
update matrix 1
`Character Spider
make object cube 1,10
position object 1,500.0,10.0,500.0
make object collision box 1,-10,-10,-10,10,10,10,1
rem setup variable to place the spider above the matrix
osy# = object size y(1) * .5
jumping = 0 : JumpCounter = 0 : grav# = 4.0
do
` Movement
if upkey() = 1 then move object 1,4.0
if downkey() = 1 then move object 1,-4.0
if leftkey() = 1 then charangy# = wrapvalue(charangy# - 2.0) : yrotate object 1, charangy#
if rightkey() = 1 then charangy# = wrapvalue(charangy# + 2.0) : yrotate object 1, charangy#
addY# = 0.0
if jumping = 1
dec JumpCounter
if JumpCounter > 9
addY# = grav# * (20 - JumpCounter)
else
if JumpCounter > 0
addY# = grav# * JumpCounter
else
JumpCounter = 0 : jumping = 0 : addY# = 0.0
endif
endif
else
if spacekey() = 1
jumping = 1 : JumpCounter = 20
endif
endif
charposx# = object position x(1)
charposz# = object position z(1)
charposy# = get ground height(1,charposx#,charposz#) + osy# + addY#
position object 1,charposx#,charposy#,charposz#
charangy# = object angle y(1)
position camera charposx#,charposy# + 30.0,charposz#
set camera to object orientation 1
move camera -60.0
point camera charposx#,charposy#,charposz#
update matrix 1
sync
loop
end
Hope this is helpful.
EDIT: I forgot that I replaced the SET CAMERA TO FOLLOW with code that manually does that. Set Camera To Follow was causing the camera to go too high when at a peak and too low when in a valley. The code I put in works much better.
LB
So many games to code.....so little time.