Indent your code better and make sure you're matching each control structure with the proper commands.
IF - ENDIF
DO - LOOP
WHILE - ENDWHILE
REPEAT - UNTIL
Every time you use one of these opening commands, everything inside of it should be indented until you close the control structure. Makes it much easier to read code and debug.
Which, it looks like you did. At first glance it was hard to tell because of the way you indented.
Unless you use a GOTO statement (which I advise you don't use), only your first block of DO-LOOP code will execute. And that
wait key at the bottom doesn't do anything since nothing will ever escape any of the loops.
Here's a better way to manage code which has multiple components.
Rem Project: Dark Basic Pro Project
Rem Created: Friday, May 02, 2014
Rem ***** Main Source File *****
make matrix 1, 100, 100, 10, 10
load image "mah swamp 2.jpg", 2
prepare matrix texture 1, 2, 1, 1
make object box 6, 100, 10, 1
position object 6, 50, 5, 0
load image "swamp wall.jpg", 8
texture object 6, 8
make object box 8, 100, 10, 1
texture object 8, 8
position object 8, 50, 5, 100
make object box 7, 1, 10, 100
texture object 7, 8
position object 7, 0, 5, 50
make object box 9, 1, 10, 100
texture object 9, 8
position object 9, 100, 5, 50
load object "Police car.3DS", 2
load image "Police car.bmp", 3
texture object 2, 3
scale object 2, 200, 200, 200
position object 2, 50, 2.5, 50
rotate object 2, 0, 180, 0
fix object pivot 2
rem play object 2
Make particles 3, 2, 50, 3
position particles 3, 50, 1 , 50
Make object cube 11, 5
color object 11, rgb (0, 0, 255)
position object 11, 75, 2.5, 75
Make object cone 12, 5
color object 12, rgb (255, 0, 0)
position object 12, 65, 2.5, 85
make object cylinder 13, 5
color object 13, rgb (0, 255, 0)
position object 13, 45, 2.5, 85
make object box 14, 5, 5, 5
color object 14, rgb (0, 255, 255)
position object 14, 35, 2.5, 75
//Load object "Android.X",30
//load image "Android.dds",32
//texture object 30,32
#CONSTANT THING_1 = 1
#CONSTANT THING_2 = 2
#CONSTANT THING_3 = 3
#CONSTANT THING_4 = 4
disable escapekey
REM ================================================
REM MAIN LOOP
REM ================================================
repeat
set cursor 0,0
print "1. Program 1"
print "2. Program 2"
print "3. Program 3"
print "4. Program 4"
print ""
print "Q. Quit"
if inkey$() = "1" then program = THING_1
if inkey$() = "2" then program = THING_2
if inkey$() = "3" then program = THING_3
if inkey$() = "4" then program = THING_4
if inkey$() = "q" then program = -1
select program
case THING_1 : gosub Thing1 : endcase
case THING_2 : gosub Thing2 : endcase
case THING_3 : gosub Thing3 : endcase
case THING_4 : gosub Thing4 : endcase
endselect
until program = -1
end
REM ================================================
REM END MAIN LOOP
REM ================================================
Thing1:
do
if upkey()
move object 2, 0.1
show particles 3
else
hide particles 3
endif
if downkey() then move object 2, -0.1
a# = object angle y(2)
if rightkey() then rotate object 2, 0, a# +0.5, 0
if leftkey() then rotate object 2, 0, a# -0.5, 0
x# = object position x(2)
y# = object position y(2)
z# = object position z(2)
position particles 3, x# - (3*sin(a#)), 0, z# - (3*cos(a#))
set camera to follow x#, y#, z#, a#, 20, 5, 1, 0
if escapekey() = 1 then exit
LOOP
RETURN
Thing2:
do
if upkey() then move object 2, 0.2
if downkey() then move object 2, -0.2
a# = object angle y(2)
if rightkey() then rotate object 2, 0, a# + 0.4, 0
if leftkey() then rotate object 2, 0, a# - 0.4, 0
if object collision(2,11) then hide object 11
if object collision(2,12) then hide object 12
if object collision(2,13) then hide object 13
if object collision(2,14) then hide object 14
if object collision(2,6) then position object 2, x#, y#, z#
if object collision(2,7) then position object 2, x#, y#, z#
if object collision(2,8) then position object 2, x#, y#, z#
if object collision(2,9) then position object 2, x#, y#, z#
x# = object position x(2)
y# = object position y(2)
z# = object position z(2)
set camera to follow x#, y#, z#, a#, 20, 5, 1, 0
if escapekey() = 1 then exit
LOOP
RETURN
Thing3:
do
if upkey() then move object 2, 1
if downkey() then move object 2, -1
a# = object angle y(2)
if rightkey() then rotate object 2, 0, a# + 0.5, 0
if leftkey() then rotate object 2, 0, a# -5, 0
x# = object position x(2)
y# = object position y(2)
z# = object position z(2)
set camera to follow x#, y#, z#, a#, 20, 5, 1, 0
if escapekey() = 1 then exit
LOOP
RETURN
Thing4:
do
if upkey() then move object 2, 1
if downkey() then move object 2, -1
a# = object angle y(2)
if rightkey() then rotate object 2, 0, a# +0.2, 0
if leftkey() then rotate object 2, 0, a# -0.2, 0
if object collision(2,0)
position object 2, x#, y#, z#
x# = object position x(2)
y# = object position y(2)
z# = object position z(2)
set camera to follow x#, y#, z#, a#, 20, 5, 1, 0
endif
//do
// rotate object 1, mousex(), mousey(), 0
//endif
if escapekey() = 1 then exit
LOOP
RETURN