; This file holds all the functions If it gets too big,
; we can split it in categories

; *****************************************************************************
; * Tileset
Procedure InitGraphics()
  GFXLogo = LoadSprite(#PB_Any, "../data/gfx/logo.bmp")
  GFXTileset = LoadSprite(#PB_Any, "../data/gfx/tileset01.bmp")
EndProcedure

; TODO: Make this dynamic
Procedure InitTileset()
  Tileset(0) = CopySprite(GFXTileset, #PB_Any)
  ClipSprite(Tileset(0), #TILE_SIZE*0, 0, #TILE_SIZE, #TILE_SIZE)
  
  Tileset(1) = CopySprite(GFXTileset, #PB_Any)
  ClipSprite(Tileset(1), #TILE_SIZE*1, 0, #TILE_SIZE, #TILE_SIZE)
  
  Tileset(2) = CopySprite(GFXTileset, #PB_Any)
  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), #TILE_SIZE*x, #TILE_SIZE*y)
EndProcedure

Procedure DrawMap()
  Define X.i ,Y.i
  
  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 DrawHUD()
EndProcedure

; *****************************************************************************
; * Menu

Procedure Menu_GotoCurrent()
  If *ActiveMenu\Entries()\Selected <> #True
    FirstElement(*ActiveMenu\Entries())
    
    ForEach *ActiveMenu\Entries()
      If *ActiveMenu\Entries()\Selected = #True
        Break
      EndIf
    Next
  EndIf
EndProcedure


