diff --git a/src/Draw.pbi b/src/Draw.pbi index 188e483..5374596 100644 --- a/src/Draw.pbi +++ b/src/Draw.pbi @@ -35,6 +35,6 @@ EndProcedure Procedure DrawRunningGame() - DrawGui() DrawMap() + DrawHUD() EndProcedure diff --git a/src/Functions.pbi b/src/Functions.pbi index 900df30..f5628c2 100644 --- a/src/Functions.pbi +++ b/src/Functions.pbi @@ -8,69 +8,36 @@ Procedure InitGraphics() GFXTileset = LoadSprite(#PB_Any, "../data/gfx/tileset01.bmp") EndProcedure +; TODO: Make this dynamic Procedure InitTileset() Tileset(0) = CopySprite(GFXTileset, #PB_Any) - ClipSprite(Tileset(0), 0, 0, 16, 16) + ClipSprite(Tileset(0), #TILE_SIZE*0, 0, #TILE_SIZE, #TILE_SIZE) Tileset(1) = CopySprite(GFXTileset, #PB_Any) - ClipSprite(Tileset(1), 16, 0, 16, 16) + ClipSprite(Tileset(1), #TILE_SIZE*1, 0, #TILE_SIZE, #TILE_SIZE) Tileset(2) = CopySprite(GFXTileset, #PB_Any) - ClipSprite(Tileset(2), 32, 0, 16, 16) + ClipSprite(Tileset(2), #TILE_SIZE*2, 0, #TILE_SIZE, #TILE_SIZE) + + Tileset(3) = CopySprite(GFXTileset, #PB_Any) + ClipSprite(Tileset(3), #TILE_SIZE*3, 0, #TILE_SIZE, #TILE_SIZE) EndProcedure Procedure DrawTile(number.i, x.i, y.i) - DisplaySprite(Tileset(number), x, y) - - ;Debug number.i - ;Debug x.i - ;Debug y.i + DisplaySprite(Tileset(number), #TILE_SIZE*x, #TILE_SIZE*y) EndProcedure Procedure DrawMap() - DrawTile(0, 0, 0); - DrawTile(0, 16, 0); - DrawTile(0, 32, 0); - DrawTile(0, 48, 0); - DrawTile(0, 64, 0); - DrawTile(0, 80, 0); - DrawTile(0, 96, 0); + Define X.i ,Y.i - DrawTile(0, 0, 16); - DrawTile(0, 16, 16); - DrawTile(0, 32, 16); - DrawTile(0, 48, 16); - DrawTile(0, 64, 16); - DrawTile(0, 80, 16); - DrawTile(0, 96, 16); - - DrawTile(1, 0, 32); - DrawTile(1, 16, 32); - DrawTile(1, 32, 32); - DrawTile(0, 48, 32); - DrawTile(1, 64, 32); - DrawTile(1, 80, 32); - DrawTile(1, 96, 32); - - DrawTile(0, 0, 48); - DrawTile(0, 16, 48); - DrawTile(0, 32, 48); - DrawTile(0, 48, 48); - DrawTile(0, 64, 48); - DrawTile(0, 80, 48); - DrawTile(0, 96, 48); - - DrawTile(2, 0, 64); - DrawTile(2, 16, 64); - DrawTile(2, 32, 64); - DrawTile(2, 48, 64); - DrawTile(2, 64, 64); - DrawTile(2, 80, 64); - DrawTile(2, 96, 64); + For X.i=Cam\X To Cam\X+Cam\Width + For Y.i=Cam\Y To Cam\Y+Cam\Height + DrawTile(TileMap(X, Y)\TileNumber, X, Y) + Next + Next EndProcedure -Procedure DrawGui() - Debug "This is an awesome Gui" +Procedure DrawHUD() EndProcedure ; ***************************************************************************** @@ -78,7 +45,7 @@ EndProcedure Procedure Menu_GotoCurrent() If *ActiveMenu\Entries()\Selected <> #True - FirstElement(*ActiveMenu\Entries()); + FirstElement(*ActiveMenu\Entries()) ForEach *ActiveMenu\Entries() If *ActiveMenu\Entries()\Selected = #True diff --git a/src/Globals.pbi b/src/Globals.pbi index 5dc51a1..db5e118 100644 --- a/src/Globals.pbi +++ b/src/Globals.pbi @@ -1,5 +1,6 @@  #DATA_PATH = "../data/" +#TILE_SIZE = 20 ; Global variables Global Fullscreen = 0 @@ -8,11 +9,15 @@ Global Screen.ScreenDimension\width = 800 Screen.ScreenDimension\height = 600 ; Player -Global Player.MapPoint\X = 10 -Player.MapPoint\Y = 10 +Global Player.Tile\X = 10 +Player.Tile\Y = 10 +Player.Tile\TileNumber = 0 -; Them map -Global Dim GameField(50, 50) +; Camera +Global Cam.Camera\X = 0 +Cam.Camera\Y = 0 +Cam.Camera\Width = Screen\Width/#TILE_SIZE +Cam.Camera\Height = Screen\Height/#TILE_SIZE NewMap GameStates.GameState() Global NewMap Menus.GameMenu() @@ -26,10 +31,23 @@ Global Font_H2 = LoadFont(2, "Verdana", 18) ; Graphics Global GFXLogo.i Global GFXTileset.i -Global Dim Tileset.i(2) +Global Dim Tileset.i(3) ; Sounds Global MenuSoundStarted = 0 LoadSound(0, #DATA_PATH + "sound/menu_change.wav") LoadSound(1, #DATA_PATH + "sound/menu_select.wav") LoadSound(2, #DATA_PATH + "sound/title_song.wav") + + +; FIXME: JUST FOR DEBUGGING +Global Dim TileMap.Tile(120, 120) +Define x, y +For x.i=0 To 120 + For y.i=0 To 120 + TileMap(x, y)\TileNumber = Random(2)+1 + TileMap(x, y)\X = x + TileMap(x, y)\Y = y + Next +Next +TileMap(3, 3)\TileNumber = 0 diff --git a/src/Main.pb b/src/Main.pb index 61a5ec9..0dcc0d2 100644 --- a/src/Main.pb +++ b/src/Main.pb @@ -87,7 +87,7 @@ If OpenWindow(0, 0, 0, Screen\Width, Screen\Height, title, #PB_Window_ScreenCent If CurrentState = "MAIN_MENU" Or CurrentState = "RLY_QUIT" If MenuSoundStarted = 0 MenuSoundStarted = PlaySound(2, #PB_Sound_MultiChannel|#PB_Sound_Loop) - SoundVolume(2, 70, MenuSoundStarted) + SoundVolume(2, 50, MenuSoundStarted) EndIf Else StopSound(2, MenuSoundStarted) diff --git a/src/Structs.pbi b/src/Structs.pbi index 4ef460f..042bb35 100644 --- a/src/Structs.pbi +++ b/src/Structs.pbi @@ -32,7 +32,15 @@ Structure GameMenu List Entries.GameMenuItem() EndStructure -Structure MapPoint +Structure Tile X.i Y.i + TileNumber.i +EndStructure + +Structure Camera + X.i + Y.i + Width.i + Height.i EndStructure