Hey everyone, I was wondering how I can move my goalkeeper along the y-axis when the space bar is pressed this is my coding:
Cerberus:
Import mojo
Function Main()
New Game_app
'This is all the game code
End
Class Game_app Extends App
Field mainmenu:Image
Field optionsmenu:Image
Field options:Image
Field paused:Image
Field gameover:Image
Field playing:Image
Global gamestate:String = "MAINMENU"
Field playingSound:Sound
Field goalkeeper:Image
Field football:Image
Method OnCreate()
'All the intialisation are her:
SetUpdateRate 60
mainmenu = LoadImage("Mainmenu.png.png")
paused = LoadImage("Paused.png.png")
playing = LoadImage("playingstate.png.png")
optionsmenu = LoadImage("Instructionsstage.png.png")
options = LoadImage("Instructionsstage.png.png")
goalkeeper = LoadImage("goalkeeper.png")
playingSound = LoadSound("playingstatesound.wav")
football = LoadImage("soccerball.png")
PlaySound(playingSound, 0, 1)
End
Method OnUpdate()
'All the game logic goes here:
Select gamestate
Case "MAINMENU"
If KeyHit (KEY_O) Then gamestate="OPTIONSMENU"
If KeyHit (KEY_ENTER) Then gamestate="PLAYING"
Case "PLAYING"
If KeyHit (KEY_P) Then gamestate="PAUSED"
If KeyHit (KEY_ESCAPE) Then gamestate="MAINMENU"
Case "OPTIONSMENU"
If KeyHit (KEY_ESCAPE) Then gamestate="MAINMENU"
If KeyHit (KEY_O) Then gamestate="MAINMENU"
Case "PAUSED"
If KeyHit (KEY_P) Then gamestate="PLAYING"
If KeyHit (KEY_O) Then gamestate="OPTIONS"
If KeyHit (KEY_ESCAPE) Then gamestate ="MAINMENU"
Case "OPTIONS"
If KeyHit (KEY_ESCAPE) Then gamestate="MAINMENU"
If KeyHit (KEY_O) Then gamestate="PAUSED"
If KeyHit (KEY_P) Then gamestate="PLAYING"
End
End
Method OnRender()
'All the graphics drawing goes here:
Cls(0, 0, 0)
Select gamestate
Case "MAINMENU"
DrawImage mainmenu , 0, 0
Case "PLAYING"
DrawImage playing, 0, 0
DrawImage goalkeeper, -405,-20
DrawImage football, -250, -72.5
Case "OPTIONS"
DrawImage options, 0, 0
Case "OPTIONSMENU"
DrawImage optionsmenu, 0, 0
Case "PAUSED"
DrawImage paused, 0, 0
End
End
End