Function main()
'This is all the game code
Class Game_app Extends App
Field Mainmenu:Image
Field Options:Image
Field paused:Image
Field gameover:Image
Global gamestate:String = "Mainmenu"
Method onCreate ()
'All the intialisation are her:
SetUpdaterate 60
Mainmenu = Loadimage ("Mainmenu.png")
End
Method onUpdata()
'All the game logic goes here:
'This is the code to allow the user to chnage between the game states
Select gamestate
Case "MAINMENU"
If KeyHit (KEY_O) Then gamestate="OPTIONS"
If KeyHit (KEY_SPACE) Then gamestate="PLAYED"
Case "PLAYING"
If KeyHit (KEY_P) Then gamestate="PAUSED"
Case "OPTIONS"
If KeyHit (KEY_ESCAPE) Then gamestate="MAINMENU"
Case "PAUSED"
If KeyHit (KEY_P) Then gamestate="PLAYING"
If KeyHit (KEY_ESCAPE) Then gamestate ="MAINMENU"
End
End
Method onRender()
'All the graphics drawing goes here:
Select gamestate
Case "MAINMENU"
DrawImage menu
Case "PLAYING"
Playing = Loadimage ("Playingstate.png")
DrawImage playing
Case "OPTIONS"
Options = Loadimage ("Instructions.png")
DrawImage playing
Case "PAUSED"
paused = Loadimage ("Paused.png")
DrawImage paused
End
End
End
'This is all the game code
Class Game_app Extends App
Field Mainmenu:Image
Field Options:Image
Field paused:Image
Field gameover:Image
Global gamestate:String = "Mainmenu"
Method onCreate ()
'All the intialisation are her:
SetUpdaterate 60
Mainmenu = Loadimage ("Mainmenu.png")
End
Method onUpdata()
'All the game logic goes here:
'This is the code to allow the user to chnage between the game states
Select gamestate
Case "MAINMENU"
If KeyHit (KEY_O) Then gamestate="OPTIONS"
If KeyHit (KEY_SPACE) Then gamestate="PLAYED"
Case "PLAYING"
If KeyHit (KEY_P) Then gamestate="PAUSED"
Case "OPTIONS"
If KeyHit (KEY_ESCAPE) Then gamestate="MAINMENU"
Case "PAUSED"
If KeyHit (KEY_P) Then gamestate="PLAYING"
If KeyHit (KEY_ESCAPE) Then gamestate ="MAINMENU"
End
End
Method onRender()
'All the graphics drawing goes here:
Select gamestate
Case "MAINMENU"
DrawImage menu
Case "PLAYING"
Playing = Loadimage ("Playingstate.png")
DrawImage playing
Case "OPTIONS"
Options = Loadimage ("Instructions.png")
DrawImage playing
Case "PAUSED"
paused = Loadimage ("Paused.png")
DrawImage paused
End
End
End