ld21-ESCape/src/Events.pbi
2011-08-20 22:52:29 +02:00

67 lines
1.6 KiB
Plaintext

; In this file, we handle alle the events
Procedure HandleEventMenu()
If KeyboardReleased(#PB_Key_Up)
PlaySound(0, #PB_Sound_MultiChannel)
Menu_GotoCurrent()
*ActiveMenu\Entries()\Selected = #False
If ListIndex(*ActiveMenu\Entries()) = 0
LastElement(*ActiveMenu\Entries())
Else
PreviousElement(*ActiveMenu\Entries())
EndIf
*ActiveMenu\Entries()\Selected = #True
EndIf
If KeyboardReleased(#PB_Key_Down)
PlaySound(0, #PB_Sound_MultiChannel)
Menu_GotoCurrent()
*ActiveMenu\Entries()\Selected = #False
If ListIndex(*ActiveMenu\Entries()) = (ListSize(*ActiveMenu\Entries())-1)
FirstElement(*ActiveMenu\Entries())
Else
NextElement(*ActiveMenu\Entries())
EndIf
*ActiveMenu\Entries()\Selected = #True
EndIf
; We go to the target game state
If KeyboardReleased(#PB_Key_Return)
PlaySound(1, #PB_Sound_MultiChannel)
Menu_GotoCurrent()
CurrentState = *ActiveMenu\Entries()\TargetState
*ActiveMenu.GameMenu = Menus(CurrentState)
EndIf
EndProcedure
Procedure HandleEventRunningGame()
If KeyboardReleased(#PB_Key_Q)
CurrentState = "MAIN_MENU"
*ActiveMenu.GameMenu = Menus(CurrentState)
EndIf
If KeyboardReleased(#PB_Key_Left) And Player\X > 0
Player\X-1
EndIf
If KeyboardReleased(#PB_Key_Right) And Player\X <= #MAP_WIDTH
Player\X+1
EndIf
If KeyboardReleased(#PB_Key_Up) And Player\Y > 0
Player\Y-1
EndIf
If KeyboardReleased(#PB_Key_Down) And Player\Y <= #MAP_HEIGHT
Player\Y+1
EndIf
EndProcedure