This is what i tried:
on the main page (note not all my code just showing what has to do with the menus)
took almost everything out of my maincode page and put it in a function called playgame()
My Mainmenu() function
my options() function
my playgame() function
Doesnt work.. it shows the main menu, but when clicking on the play button (change selection to = 2, in thoery calling the playgame() function.)
but it just sits there...
on the main page (note not all my code just showing what has to do with the menus)
took almost everything out of my maincode page and put it in a function called playgame()
Global selection=1 ;If selection=1 Mainmenu() ;If selection=2 playgame() ;If selection=3 options() While Not KeyHit(1) ; loop until ESC is pressed If selection = 1 Then Mainmenu() ; main menu sets selection to 2 if the play game button is pressed or sets selection to 3 if the options button is pressed. ElseIf selection = 2 Then playgame() ; move game code into its own function. When game ends set selection = 1 again to show the main menu. ElseIf selection = 3 Then options() ; display the options menu. When the back button is pressed, set selection to 1 and the main menu will be shown. End If Wend
My Mainmenu() function
Function Mainmenu() Graphics 800,600,32,2 mainimage=LoadImage("mainmenu.png") continue=LoadImage("Playbutton.png") ;mouse=LoadImage("mouse.png") MaskImage continue,255,0,255 While Not KeyHit(1) ;mouse_x=MouseX() ;mouse_y=MouseY() Cls DrawImage mainimage,0,0 DrawImage continue,100,400 ;DrawImage mouse,mouse_x,mouse_y Flip If ImageRectCollide(continue,100,400,0,MouseX(),MouseY(),5,5) And MouseHit(1) selection=2 End If If KeyHit(2) selection=3 End If Delay 5 Wend End Function
my options() function
;Options Function options() Graphics 800,600,32,2 Backbutton=LoadImage("Backbuttons.png") DrawImage backbutton,0,0 While Not KeyHit(1) If ImageRectCollide(backbutton,0,0,0,MouseX(),MouseY(),5,5) And MouseHit(1) selection=1 End If Delay 5 Wend End Function
my playgame() function
Function playgame() Graphics 800,600,32,2 ;Mid handles all of the images and creates a image called paddle. HidePointer AutoMidHandle True paddle=CreateImage(70,15) ball=CreateImage(10,10) AutoMidHandle False pausedpic=LoadImage("Paused.png") ;draws on the empty image container.. SetBuffer ImageBuffer(paddle) Rect 0,0,70,15,1 SetBuffer ImageBuffer(ball) Oval 0,0,10,10,1 SetBuffer BackBuffer() ;Copys the ball image 3 times these will be our lifes displayed on the bottom of the screen. life1=CopyImage(ball) life2=CopyImage(ball) life3=CopyImage(ball) While Not KeyHit(1) Cls ;Calls functions. addplayercontrols() drawmyimages() addcollisions() addtext() ;conditional functions If KeyHit(P) Pause(pausedpic) End If ;small delay in the loop for less slow down. ;flips, ends the loop and termanates the program.. Delay 5 Flip Wend End End Function
Doesnt work.. it shows the main menu, but when clicking on the play button (change selection to = 2, in thoery calling the playgame() function.)
but it just sits there...