From 480ddca93546554c89276f6dee980baf93adac95 Mon Sep 17 00:00:00 2001 From: Aaron Date: Sat, 20 Aug 2011 22:52:29 +0200 Subject: [PATCH] Player is movin --- src/Draw.pbi | 1 + src/Events.pbi | 19 +++++++++++++++++++ src/Functions.pbi | 5 +++++ src/Globals.pbi | 5 +++-- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/Draw.pbi b/src/Draw.pbi index 5374596..dd4dfae 100644 --- a/src/Draw.pbi +++ b/src/Draw.pbi @@ -36,5 +36,6 @@ EndProcedure Procedure DrawRunningGame() DrawMap() + DrawPlayer() DrawHUD() EndProcedure diff --git a/src/Events.pbi b/src/Events.pbi index 83fe572..bfe8f63 100644 --- a/src/Events.pbi +++ b/src/Events.pbi @@ -45,4 +45,23 @@ Procedure HandleEventRunningGame() 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 \ No newline at end of file diff --git a/src/Functions.pbi b/src/Functions.pbi index f5628c2..6adefef 100644 --- a/src/Functions.pbi +++ b/src/Functions.pbi @@ -37,9 +37,14 @@ Procedure DrawMap() Next EndProcedure +Procedure DrawPlayer() + DrawTile(Player\TileNumber, Player\X, Player\Y) +EndProcedure + Procedure DrawHUD() EndProcedure + ; ***************************************************************************** ; * Menu diff --git a/src/Globals.pbi b/src/Globals.pbi index db5e118..4411e12 100644 --- a/src/Globals.pbi +++ b/src/Globals.pbi @@ -1,6 +1,8 @@  #DATA_PATH = "../data/" #TILE_SIZE = 20 +#MAP_WIDTH = 120 +#MAP_HEIGHT = 120 ; Global variables Global Fullscreen = 0 @@ -41,7 +43,7 @@ LoadSound(2, #DATA_PATH + "sound/title_song.wav") ; FIXME: JUST FOR DEBUGGING -Global Dim TileMap.Tile(120, 120) +Global Dim TileMap.Tile(#MAP_WIDTH, #MAP_HEIGHT) Define x, y For x.i=0 To 120 For y.i=0 To 120 @@ -50,4 +52,3 @@ For x.i=0 To 120 TileMap(x, y)\Y = y Next Next -TileMap(3, 3)\TileNumber = 0