i did something similar some time ago
maybe it will help
rem Generic Template
set display mode 1024,768,32
SYNC ON
SYNC RATE 60
backdrop on
color backdrop rgb(10,100,100)
autocam off
set global collision off
cx#=0.0:cy#=0.0:cz#=0.0:ca#=0.0:camght=50
camrot=0:camdist=0:campointh=0
gosub Setupland1
gosub make_player
gosub make_enemy
gosub setcam
gosub play_game
do
if inkey$()="e" then sync rate 0
if inkey$()="E" then sync rate 60
gosub printdata
if inkey$()="p" then gosub play_game
SYNC
loop
rem -------------ROUTINES--------------------
play_game:
playerx=rnd(grid-1)+1:playerz=rnd(grid-1)+1
px#=playerx*span:pz#=playerz*span
position object 11,px#-span/2,0.0,pz#-span/2
enemyx=rnd(grid-1)+1:enemyz=rnd(grid-1)+1
ex#=enemyx*span:ez#=enemyz*span
position object 12,ex#-span/2,0.0,ez#-span/2
ptxnum=int(px#/span)
ptznum=int(pz#/span)
etxnum=int(ex#/span)
etznum=int(ez#/span)
wait 500
return
setcam:
set camera range 1,20000
camdist=-600
camhgt=1200
position camera landsize/2,camhgt,camdist
point camera landsize/2,0.0,landsize/2
return
printdata:
set cursor 0,0
print "Polys=",statistic(1)
print "FPS=",screen fps()
print
print "player xtile = ",ptxnum
print "player ztile = ",ptznum
print
print "enemy xtile = ",etxnum
print "enemy ztile = ",etznum
print
print " PRESS P TO PLAY"
return
Setupland1:
rem ground textures
rem create texture
cls rgb(0,100,20)
inkcolor#=rgb(255,255,255)
line 0,0,0,250
line 1,1,1,250
line 2,2,2,250
line 0,0,250,0
line 1,1,250,1
line 2,2,250,2
rem next n
get image 2,0,0,250,250
rem Make landscape
span=200:grid=10:landsize=span*grid
make matrix 1,landsize,landsize,grid,grid
set matrix 1,1,0,0,1,1,1,1
prepare matrix texture 1,2,1,1
randomize matrix 1,0
rem ***********
rem get ground done
update matrix 1
return
rem -------------Characters----------------
make_player:
make object cube 11,80
color object 11,rgb(200,0,0)
return
make_enemy:
make object sphere 12,80
color object 12,rgb(0,0,200)
return
end