I have set the function for the main menu and it works at the start, but whenever I want the game loop to go back to the menu function after the player loses, it just doesnt work. Any help? Here's my code:
sync on
sync rate 30
Disable escapekey
gosub mnuvars
do
if selecteditem <> 0
Ink white, white
Center text screen width ()/2, 200, mnuitems$(0)
Else
Ink red, red
center text screen width()/2, 200, mnuitems$(0)
endif
if selecteditem <> 1
Ink white, white
Center text screen width ()/2, 220, mnuitems$(1)
Else
Ink red, red
center text screen width()/2, 220, mnuitems$(1)
Endif
if keystate(17) = 0 and up = 1
up = 0
endif
if keystate(17) = 1 and up = 0
selecteditem = selecteditem - 1
up = 1
endif
if keystate(31) = 0 and down = 1
down = 0
endif
if keystate(31) = 1 and down = 0
selecteditem = selecteditem + 1
down = 1
endif
if selecteditem < 0
selecteditem = 1
endif
if selecteditem > 1
selecteditem = 0
endif
if selecteditem = 0 and returnkey()
GoSub gameloop
endif
sync
sync
loop
mnuvars:
dim mnuItems$(1)
mnuItems$(0)="New Game"
mnuItems$(1)="Exit"
selecteditem = 0
up = 0
down = 0
red = RGB(255, 0, 0)
white = RGB(255, 255, 255)
Return
gameloop:
load animation "C:\Users\pc\Documents\Bandicam\bandicam 2015-11-18 20-13-15-363.avi", 3
load animation "C:\Users\pc\Documents\Bandicam\bandicam 2015-11-18 20-06-54-071.avi", 2
load animation "C:\Users\pc\Documents\Bandicam\bandicam 2015-11-18 20-17-54-048.avi", 1
play animation 3
do
gosub setanim
sync
loop
setanim:
animflag = 0
for i = 1 to 2
if animation playing (i) = 1 then animflag = 1
next i
if animflag = 0 and keystate(2) = 1 or animflag = 0 and keystate(3) = 1 or animflag = 0 and keystate(4) = 1 or animflag = 0 and keystate(5) = 1
NUMB = 1 + rnd(1)
play animation NUMB
sync
randomize timer()
if animation exist(3)
delete animation 3
endif
endif
return
return