Hello
I'm new to Dark Basic and Dark Basic Pro. I'm making a maze game, the object is to move through it to the exit as quickly as possible. I have a cube at the exit to detect when user is finished, it disappears when sphere collides with it. I have a timer counting down the time from 40 seconds. The problem is, when I try to call the High Score screen just after the collision for the cube at end is set, it doesn't work. It changes the window title, but cls does nothing and the high score screen doesn't come up.
I have four seperate files with my code in it, here is code:
Rem ***** Included Source File *****
Set Window Title "Main Menu"
ShowMainMenuBox()
Function ShowMainMenuBox()
white as DWORD
black as DWORD
blue as DWORD
grey as DWORD
white = rgb(255,255,255)
black = rgb(0,0,0)
blue = rgb(0,0,255)
grey = rgb(190,190,190)
box 0,0,640,480,black,blue,black,blue
ink black,black
box 160,90,480,290
ink white,white
box 162,92,478,288
box 162,92,478,102,white,grey,white,grey
box 162,278,478,288,grey,white,grey,white
ink black,white
center text 320,112,"DarkBASIC Professional"
center text 320,132,"presents"
center text 320,152,"A Maze Production"
center text 320,172,"Maze Game!"
center text 320,212,"Instructions"
center text 320,232,"Play Game"
center text 320,252,"High Scores"
do
// Instructions
if mousex()>=275 and mousex()<=370 and mousey()>=212 and mousey()<=227 and mouseclick()
Instructions()
Endif
// Play Game
if mousex()>=285 and mousex()<=355 and mousey()>=232 and mousey()<=247 and mouseclick()
Game()
Endif
// High Scores
if mousex()>=275 and mousex()<=365 and mousey()>=252 and mousey()<=267 and mouseclick()
HighScores()
Endif
loop
EndFunction
Rem ***** Included Source File *****
Function Instructions()
CLS
Set Window Title "Instructions"
white as DWORD
black as DWORD
blue as DWORD
grey as DWORD
white = rgb(255,255,255)
black = rgb(0,0,0)
blue = rgb(0,0,255)
grey = rgb(190,190,190)
box 0,0,640,480,black,blue,black,blue
ink black,black
box 160,90,480,290
ink white,white
box 162,92,478,288
box 162,92,478,102,white,grey,white,grey
box 162,278,478,288,grey,white,grey,white
ink black,white
center text 320,112,"Instructions"
do
// Main Menu
if mousex()>=250 and mousex()<=385 and mousey()>=112 and mousey()<=122 and mouseclick()
ShowMainMenuBox()
Endif
loop
EndFunction
Function Game()
CLS
Set Window Title "Game"
Sync On
Sync Rate 60
//CreateLevel()
/////////////////////////// MAKING MAP ON TOP OF MATRIX ////////////////////////////
make object box 10, 32, 100, 32
position object 10, 35, 0, 0
make object cube 11, 50
position object 11, 1040, 20, 880
//make object cylinder 11, 8
make mesh from object 1, 10
// delete object 10
// add limb 10, 1, 1
// add limb 10, 2, 1
// add limb 10, 3, 1
// add limb 10, 4, 1
// offset limb 10, 1, 8, 6, 8
// offset limb 10, 2, -8, 6, 8
// offset limb 10, 3, 8, 6, -8
// offset limb 10, 4, -8, 6, -8
// make mesh from object 1, 10
// delete object 10
// delete object 11
restore Level
o1 = 1000
o2 = 2000
o3 = 3000
do
read l$
if l$ = "EOL" then exit
for lx = 1 to len(l$)
c$ = mid$(l$, lx)
if c$ = "#"
inc o2
make object o2, 1, 0
position object o2, (lx - 1) * 32, 0, lz * 32
color object o2, RGB(255,0,0)
set object collision to boxes o2
endif
next lx
inc lz
loop
/////////////////////////// END OF MAKING MAP ON TOP OF MATRIX ////////////////////////////
//load image "U:\2013-14 Tech Work\Trimester Two\Michael - Game Dev\Game\floor.jpg",1
load image "C:\Users\Benjamin#\Desktop\floor.jpg",1
make matrix 1,1200,1200,10,10
//position matrix 1,0,-5,0
prepare matrix texture 1,1,2,2
//ink RGB(255,0,0),0
Make Object Sphere 1,20
//mpY# = matrix position y(1)
position object 1,500,5,450
score = 0
Seconds = 40
T = Timer()
Repeat
Elapsed=(Timer()-T)/1000
TimeLeft=Seconds-Elapsed
Text 0,0,Str$(TimeLeft)+" "
Set text size 50
//Text 200,0,Str$(score)
Rem Store Object angle Y in aY#
aY# = Object angle Y(1)
Rem Control input for camera
If Upkey()=1 then
Move object 1,5
If Leftkey()=1 then
aY# = wrapvalue(aY#-5)
If Rightkey()=1 then
aY# = wrapvalue(aY#+5)
Yrotate object 1,aY#
If Object collision(1,11)>0 then
hide object 11
cls
HighScores()
If Object collision(1,0)>0 then
position object 1,X#,6,Z#
Rem get player object position and store in X# and Z#
X# = Object position x(1)
Z# = Object position z(1)
Rem get new camera position and store in cZ# and cX#
cZ# = Newzvalue(Z#,aY#-180,100)
cX# = Newxvalue(X#,aY#-180,100)
Rem position camera
//Position Camera cX#,5,cZ#
Position Camera cX#,250,cZ#
Rem point the camera at the player object
//Point camera X#,5,Z#
Point camera X#,150,Z#
If TimeLeft=0 Then
Print "Score: " + str$(score)
sync
Until TimeLeft=0
// cls
// HighScores()
//Print "Score: " + str$(score)
// load image "U:\2013-14 Tech Work\Trimester Two\Michael - Game Dev\Game\wall.jpg",2
// load image "C:\Users\Benjamin#\Desktop\wall.jpg",2
EndFunction
Level:
data "################################"
data "# #"
data "# ###### ######### #"
data "# # # # #"
data "# # # # ###### #"
data "# # ###### # #"
data "# # # # ######### #"
data "# # # # #"
data "# ####### #### ###### #"
data "# # # #"
data "# # # # #"
data "# # # #### ####### #"
data "# # # # # #"
data "# ##### # ######## #"
data "# # # # #"
data "# ##### ########## #######"
data "# # #"
data "# ###### ############ ######"
data "# # # # # #"
data "# ### # # ## ## # # #"
data "# # # # # # #"
data "######### #### #### # #"
data "######### # #"
data "# ## ##### ######"
data "# ## ###### # # # ###"
data "# ## # # # # ###"
data "# #### # # # ########"
data "##### # ## "
data "# # ########## # ## ## "
data "# ### # # # ##### #"
data "# # #"
data "################################"
data "EOL"
Rem ***** Included Source File *****
Function HighScores()
CLS
Set Window Title "High Scores"
white as DWORD
black as DWORD
blue as DWORD
grey as DWORD
white = rgb(255,255,255)
black = rgb(0,0,0)
blue = rgb(0,0,255)
grey = rgb(190,190,190)
box 0,0,640,480,black,blue,black,blue
ink black,black
box 160,90,480,290
ink white,white
box 162,92,478,288
box 162,92,478,102,white,grey,white,grey
box 162,278,478,288,grey,white,grey,white
ink black,white
center text 320, 112,"High Scores"
// Input choice
//
// Select choice
//
// Case 1
// ShowMainMenuBox()
// EndCase
//
// EndSelect
do
// Main Menu
if mousex()>=270 and mousex()<=385 and mousey()>=112 and mousey()<=122 and mouseclick()
ShowMainMenuBox()
Endif
loop
EndFunction
I have been working at this particular error for a week now, and I have tried everything I can think of and find online. I don't know how to sort this out. Any ideas?
Thank you