the step into 3d is easier in db but not so obvious from the get go.
A game is basically these steps
the start
the menu
the game data setup
the pre game loop stuff
the actual game loop
the cleanup
the end
In order to excell in 3d its best to know how to visualise the 3d objects in space. Consider the xyz dimensions of an object.
Imagine in your game theres a ground zero location 0,0,0
Know that the x dimension represents the left / right
Know that the x dimension represents the up / down
Know that the z dimension represents the forwards / backwards
Both directions are represented by negative and positive values from the zero point.
ok lets put it into practise now in the smallest of programs with a basic shell to get started.
rem ------------------------------------------------------
rem 3D Game Shell for DarkBasic
rem date :
rem author :
rem notes :
rem
rem -------------------------------------------------------
rem the basic setup
sync on : sync rate 60
rem the basic ink and text setup
ink rgb(255,255,0),1
set text size 13
set text font "verdana"
rem a simple menu
center text screen width()/2,screen height()/2,"A Basic 3d game shell"
center text screen width()/2,screen height()/2+16,"press a key to start"
sync
suspend for key
rem the game data load area
make object cube 1,5
rem premain
disable escapekey
rem the main loop starts
while escapekey()=0
rem spin the cube for something to visualise
r = wrapvalue(r)+1
rotate object 1,r,r,r
rem update the text last in your loop
center text screen width()/2,1,"press escape to end"
rem sync at the end of the loop to update the screen here
sync
rem end the loop
endwhile
rem clean up safely
delete object 1
rem end program
end
I want to add some info here about the above code.
We didnt position the object so DB assumes 0,0,0 is its location
We didnt position the camera so DBs camera automatically locks onto it.
lets look at snippet two now
rem ------------------------------------------------------
rem 3D Game Shell for DarkBasic
rem date :
rem author :
rem notes :
rem
rem -------------------------------------------------------
rem the basic setup
sync on : sync rate 60
rem the basic ink and text setup
ink rgb(255,255,0),1
set text size 13
set text font "verdana"
rem a simple menu
center text screen width()/2,screen height()/2,"A Basic 3d game shell"
center text screen width()/2,screen height()/2+16,"press a key to start"
sync
suspend for key
rem the game data load area
make object cube 1,5
position object 1,0,0,0
rem premain
rem position the camera up and back from model
position camera 0,10,-10
rem point camera at 0,0,0
point camera 0,0,0
disable escapekey
rem the main loop starts
while escapekey()=0
rem spin the cube for something to visualise
r = wrapvalue(r)+1
rotate object 1,r,r,r
rem update the text last in your loop
center text screen width()/2,1,"press escape to end"
rem sync at the end of the loop to update the screen here
sync
rem end the loop
endwhile
rem clean up safely
delete object 1
rem end program
end
At the end of the day tho you will ultimately decide where things go by asking yourself is it faster this way and can i leave out of my main game loop.
its easy to break your program down into these areas and then break each area down again when things get more complicated.
the start
the menu
the game data setup
the pre game loop stuff
the actual game loop
the cleanup
the end
this is a minor introduction to the 3d aspect.