; 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 CompilerSelect #PB_Compiler_OS CompilerCase #PB_OS_Linux GenerateShadowLayer() CompilerEndSelect ; Player movement If KeyboardReleased(#PB_Key_Left) And Player\X > 0 If TileIsType(#TILESET_TYPE_FLOOR, Player\X-1, Player\Y) Or TileIsType(#TILESET_TYPE_GRASS, Player\X-1, Player\Y) Player\X-1 EndIf ; Camera positioning If Player\X < (Cam\X + Cam\Padding) And Cam\X > 0 Cam\X - 1 EndIf EndIf If KeyboardReleased(#PB_Key_Right) And Player\X < #MAP_WIDTH-1 If TileIsType(#TILESET_TYPE_FLOOR, Player\X+1, Player\Y) Or TileIsType(#TILESET_TYPE_GRASS, Player\X+1, Player\Y) Player\X+1 EndIf ; Camera positioning If Player\X > (Cam\X + Cam\Width - Cam\Padding) And (Cam\X + Cam\Width) < #MAP_WIDTH-1 Cam\X + 1 EndIf EndIf If KeyboardReleased(#PB_Key_Up) And Player\Y > 0 If TileIsType(#TILESET_TYPE_FLOOR, Player\X, Player\Y-1) Or TileIsType(#TILESET_TYPE_GRASS, Player\X, Player\Y-1) Player\Y-1 EndIf ; Camera positioning If Player\Y< (Cam\Y + Cam\Padding) And Cam\Y > 0 Cam\Y - 1 EndIf EndIf If KeyboardReleased(#PB_Key_Down) And Player\Y < #MAP_HEIGHT-1 If TileIsType(#TILESET_TYPE_FLOOR, Player\X, Player\Y+1) Or TileIsType(#TILESET_TYPE_GRASS, Player\X, Player\Y+1) Player\Y+1 EndIf ; Camera positioning If Player\Y > (Cam\Y + Cam\Height - Cam\Padding) And (Cam\Y + Cam\Height) < #MAP_HEIGHT-1 Cam\Y + 1 EndIf EndIf EndProcedure ; IDE Options = PureBasic 4.51 (Linux - x64) ; CursorPosition = 98 ; FirstLine = 52 ; Folding = - ; EnableXP ; EnableCompileCount = 0 ; EnableBuildCount = 0