hi, i'm making a game with many mini-games... so i use a sub for each minigame... i have a variable called game, and i assign a minigame to its values... so i wrote:
i wrote in sub minigame 1:
Code (glbasic) Select
select game
case 1
gosub minigame1
case 2
gosub minigame2
...
endselect
in every minigame i must have variables, so i defined them local; i have a variable called phase that has values 0,1 or 2:i wrote in sub minigame 1:
Code (glbasic) Select
if phase=0
//just a loading phase: creates all the variables and arrays or load the sprites...
LOCAL score; score=0
LOCAL time; time=2000
...
phase=1
endif
if phase=1
//show the instructions(here is the code to show the instructions)
if key(28)
phase=2
endif
endif
if phase=2
//play the game(and here's is all the code of the real minigame)
if time<0 then phase=0 //go back to the loading phase and to the instructions if there is no more time
endif
but the LOCAL variables don't work,.. the time should be 2000 at the beginning of the game, and it is 0. so it returns to the instructions... why does it happen? if i define the variables as global variables then it works ok... but if i define them LOCAL the game doesn't work...