I'm new to Darkbasic, and on my third day of learning it, I've created this a "DEMO". But I don't know how to position my character in the middle of my matrix. Can somebody help? Also, how would I go about making an invisible border so that the character cannot go outside the matrix?
rem **************************
rem ** DEMO **
rem ** Created By: **
rem ** Martin vanPutten **
rem **************************
rem Start Up Screen.
cls
print "DEMO"
print "Created By: Martin vanPutten"
sleep 1000
print "Loading..."
sleep 5000
rem Setup Environment.
hide mouse
autocam off
sync on
rem Prepare Ground For The Matrix.
Load bitmap "Ground.bmp", 1
Get Image 1, 0, 0, 128, 128
Delete Bitmap 1
rem Create Ground.
Make Matrix 1, 10000, 10000, 15, 15
Prepare Matrix Texture 1, 1, 1, 1
rem Load Charecter.
load object "idle.x", 1 : append object "walk.x", 1, 100
yrotate object 1, 180 : fix object pivot 1
position object 1, 10000, 0, 10000
loop object 1, 0, 20 : set object speed 1, 5
rem Game Loop.
do
rem Variables.
aY# = Object angle Y(1)
rem Player Movement.
stage=0
if Leftkey() = 1 then a# = a# - 9.0 : a# = wrapvalue(aY# - 4.5)
if Rightkey() = 1 then a# = a# + 9.0 : a#=wrapvalue(aY# + 4.5)
if Upkey() = 1 then x# = NewxValue(x#, a#, +12) : z# = NewzValue(z#, a#, +12) : stage = 1
if Downkey() = 1 then x# = NewxValue(x#, a#, -12) : z# = NewzValue(z#, a#, -12) : stage = 1
position object 1, x#, 0.0, z#
yrotate object 1, a#
rem Controling Player Animation.
if stage <> oldstage
if stage = 0
set object frame 1, 0.0
loop object 1, 0, 20
set object speed 1, 10
endif
if stage = 1
set object frame 1, 105.0
loop object 1, 105, 125
set object speed 1, 40
endif
oldstage = stage
endif
rem Camera Control.
cZ# = Newzvalue(Z#, aY# - 180, 300)
cX# = Newxvalue(X#, aY# - 180, 300)
Position Camera cX#, 200, cZ#
Point camera X#, 150, Z#
rem Refresh Screen.
sync
rem End Game Loop.
loop
~Live And Let Learn~