why does my program crash
I'am testing a game menu
here is the code
no media needed
REM Project: Game menu
REM Created: 01/07/2009 12:50:45
REM
REM ***** Main Source File *****
REM
Set display mode 1024,768,32
Sync on
Sync rate 60
Disable escapekey
Gosub mnuvars
Gosub Start
Start:
repeat
Viewmenu()
Sync
Until menu_end=1
mnuvars:
Dim mnuitem$(5)
mnuitem$(0)="NEW GAME"
mnuitem$(1)="LOAD GAME"
mnuitem$(2)="SAVE GAME"
mnuitem$(3)="OPTIONS"
mnuitem$(4)="EXIT"
global selecteditem = 0
global up = 0
global down = 0
global menushow = 0
global menu_end = 0
global red as dword = rgb(255,0,0)
global white as dword = rgb(255,255,255)
Return
Game:
set display mode 1024,768,32
make object cube 1,40
color object 1,rgb(0,255,0)
position object 1,0,0,0
position camera 0,0,100,-200
point camera 0,0,0
make matrix 1,10000,10000,100,100
Do
if escapekey()=1 and menushow=0
menushow=1
endif
if rightkey()=1
turn object right 1,4
endif
if leftkey()=1
turn object left 1,4
endif
if upkey()=1
move object 1,4
endif
if downkey()=1
move object 1,-4
endif
if menushow=1
Viewmenu()
endif
sync
loop
Function Viewmenu()
set display mode 800,600,32
If selecteditem <> 0
ink rgb(255,255,255),rgb(255,255,255)
center text screen width()/2,200,mnuitem$(0)
Else
ink rgb(255,0,0),rgb(255,0,0)
center text screen width()/2,200,mnuitem$(0)
Endif
If selecteditem <> 1
ink rgb(255,255,255),rgb(255,255,255)
center text screen width()/2,220,mnuitem$(1)
Else
ink rgb(255,0,0),rgb(255,0,0)
center text screen width()/2,220,mnuitem$(1)
Endif
If selecteditem <> 2
ink rgb(255,255,255),rgb(255,255,255)
center text screen width()/2,240,mnuitem$(2)
Else
ink rgb(255,0,0),rgb(255,0,0)
center text screen width()/2,240,mnuitem$(2)
Endif
If selecteditem <> 3
ink rgb(255,255,255),rgb(255,255,255)
center text screen width()/2,260,mnuitem$(3)
Else
ink rgb(255,0,0),rgb(255,0,0)
center text screen width()/2,260,mnuitem$(3)
Endif
If selecteditem <> 4
ink rgb(255,255,255),rgb(255,255,255)
center text screen width()/2,280,mnuitem$(4)
Else
ink rgb(255,0,0),rgb(255,0,0)
center text screen width()/2,280,mnuitem$(4)
Endif
if upkey()=0 and up=1
up=0
endif
if upkey()=1 and up=0
selecteditem = selecteditem - 1
up=1
endif
if downkey()=0 and down=1
down=0
endif
if downkey()=1 and down=0
selecteditem = selecteditem + 1
down=1
endif
if selecteditem < 0
selecteditem = 4
endif
if selecteditem > 4
selecteditem = 0
endif
if selecteditem = 4 and returnkey()=1
end
endif
if selecteditem = 0 and returnkey()=1
goto game
endif
if menushow=1 and escapekey()=1
menushow=0
endif
Endfunction
thanx for help