Menu Freezing
BlitzPlus Forums/BlitzPlus Programming/Menu Freezing
| ||
The menu will work at first but when you use the "Main Menu" button or go back to the menu in any way after using it the menu will freeze. Does anyone know why? All suggestions are welcome. Heres the code. Thanks! Graphics 800,600 AutoMidHandle True SeedRnd MilliSecs() Global result result = menu() If result = 1 Then writem() If result = 2 Then readm() If result = 3 Then End While Not KeyDown(1) Wend End Function menu() Cls Rect(300,90,200,50,0) Text(325,110,"Write Code Message") Rect(300,290,200,50,0) Text(325,310,"Read Code Message") Rect(300,490,200,50,0) Text(360,510,"Quit") While result = 0 If MouseHit(1) Then If RectsOverlap(300,90,200,50,MouseX(),MouseY(),1,1) Then result = 1 If RectsOverlap(300,290,200,50,MouseX(),MouseY(),1,1) Then result = 2 If RectsOverlap(300,490,200,50,MouseX(),MouseY(),1,1) Then result = 3 EndIf Wend Return result End Function Function writem() Cls seedresult = seedmenu() If seedresult = 1 Then seed = Rand(1,100) Cls Text 300,200,"Seed = " + seed EndIf If seedresult = 2 Then Cls seed = Input("Enter Seed (Must Be Between 1 and 100)") If seed > 100 Then Cls Text 400,200,"Invalid Seed, Press Any Ket To Try Again" WaitKey seedmenu() EndIf EndIf If seedresult = 3 Then menu() End Function Function readm() Cls Text 300,200,"Read" End Function Function seedmenu() Cls Rect(300,90,200,50,0) Text(325,110,"Random Seed") Rect(300,290,200,50,0) Text(325,310,"Create Seed") Rect(300,490,200,50,0) Text(360,510,"Main Menu") While seedresult = 0 If MouseHit(1) Then If RectsOverlap(300,90,200,50,MouseX(),MouseY(),1,1) Then seedresult = 1 If RectsOverlap(300,290,200,50,MouseX(),MouseY(),1,1) Then seedresult = 2 If RectsOverlap(300,490,200,50,MouseX(),MouseY(),1,1) Then seedresult = 3 EndIf Wend Return seedresult End Function |
| ||
yea because result is global you'll want to reset it to 0 when you go back because when your code hits the While result = 0 part result still has the same value from the last time it was used. |