basically i used to use DBC a couple of years ago but i haven't done anything vaguely related to programming in god knows how long and i was never exactly great at it so i'm trying to start from scratch. i'm making a simple program to get used to using the language again but the get ground height command doesn't seem to be working... my little spherey bloke keeps sinking into the ground, and it's movement is quite erratic as it jumps between the different heights instead of sliding smoothly from one to another.
this is my code:
sync rate 30
sync on
rem load textures
load bitmap "textures.bmp",1
get image 1,0,0,128,128
get image 2,128,0,384,256
get image 3,0,128,128,256
delete bitmap 1
rem make matrix
make matrix 1,510.0,510.0,25,25
position matrix 1,-75,0,-75
randomize matrix 1,10
prepare matrix texture 1,2,2,2
rem make character
make object sphere 1,10
texture object 1,1
objya#=get ground height(1,0,0)
objy#=objya#+5
position object 1,0,objy#,0
rem position camera
position camera -50,50,-50
point camera 0,0,0
rem create fog
fog on
fog color rgb(100,100,100)
fog distance 500
color backdrop rgb(100,100,100)
while keystate(45)=0
rem move character
if upkey()=1
move object 1,-1
endif
if downkey()=1
move object 1,1
endif
angle#=object angle y(1)
if leftkey()=1 then angle#=wrapvalue(angle#-13)
if rightkey()=1 then angle#=wrapvalue(angle#+13)
yrotate object 1,angle#
rem place object above ground
objx#=object position x(1)
objz#=object position z(1)
objya#=get ground height(1,objx#,objz#)
objy#=objya#+5
position object 1,objx#,objy#,objz#
rem show instructions
paste image 3,512,0,1
sync
endwhile
sync off
delete object 1
delete matrix 1
delete image 1
delete image 2
delete image 3
backdrop off
cls
end
the problem is probably in this bit:
rem place object above ground
objx#=object position x(1)
objz#=object position z(1)
objya#=get ground height(1,objx#,objz#)
objy#=objya#+5
position object 1,objx#,objy#,objz#
the only external media I am using is one picture with 2 128x128 squares on the left and one 256x256 texture included with darkbasic on the right.
can someone help me? it's probably something stupid but I don't know what I've done...
RIP Dimebag
http://db1games.topcities.com
(used to be demonsbreath)