I want to restart my game but having a few problems.
Here is a few snippets. My Main DO-LOOP, win and defeat function.
start:
`--------------------------MAIN LOOP-------------------------
DO
move()
newammo()
gold()
enemies()
hud()
clock()
cheats()
ai update
IF killcount = 20
win()
ENDIF
IF health = 0
defeat()
ENDIF
IF returnToMenu=1
REM -------- Delete all objects if they EXIST --------
FOR delete = 1 to 30
IF OBJECT EXIST (delete) THEN DELETE OBJECT delete
NEXT delete
FOR delete = 501 to 520
IF OBJECT EXIST (delete) THEN DELETE OBJECT delete
NEXT delete
FOR delete = 40 to 44
IF IMAGE EXIST (delete) THEN DELETE IMAGE delete
NEXT delete
FOR delete = 1000 to 1004
IF IMAGE EXIST (delete) THEN DELETE IMAGE delete
NEXT delete
FOR delete = 200 to 201
If SOUND EXIST (delete) THEN DELETE SOUND delete
NEXT delete
FOR delete = 202 to 203
If MUSIC EXIST (delete) THEN DELETE MUSIC delete
NEXT delete
DELETE STATIC OBJECT 0
DELETE OBJECT e+1000
EXIT
ENDIF
sync
LOOP
GOSUB start
Here is my win and defeat functions.
Both functions work they appear when player has won or died.
But they wont go back to the start of the game, after i have pressed any button.
FUNCTION win()
CLS
STOP MUSIC 202
LOAD IMAGE "media/images/win.bmp",1002
PASTE IMAGE 1002,0,0
ink rgb(248,8,8),rgb(0,0,0)
returnToMenu=1
x = screen width()/2
center text x,400, "Congratulations " + name$
center text x,450, "You killed all of those darn robots!"
`center text x,500, "You Scored: "
`center text x,550, "You collected: " + GoldBars + "/3 Gold Bars"
center text x,600, "Press any key to return to the main menu"
WAIT KEY
EXIT
ENDFUNCTION
FUNCTION defeat()
CLS
STOP MUSIC 202
LOAD IMAGE "media/images/defeatdeath.bmp",1003
PASTE IMAGE 1003,0,0
ink rgb(248,8,8),rgb(0,0,0)
returnToMenu=1
x = screen width()/2
center text x,400, "Sorry " + name$
center text x,450, "Those robots were just too fast!"
`center text x,500, "You Scored: "
`center text x,550, "You collected: " + GoldBars + "/3 Gold Bars"
center text x,600, "Press any key to return to the main menu"
WAIT KEY
EXIT
ENDFUNCTION
If anyone has an idea whats wrong would be greatful.
Note
im using a dbo for my level which is the static object 0