#if B4A
'ignore DIP related warnings as they are not relevant when working with BitmapCreator.
#IgnoreWarnings: 6
#end if
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
Sub Class_Globals
    Public X2 As X2Utils
    Private xui As XUI 'ignore
    Public world As B2World
    Public Ground As X2BodyWrapper
    Private ivForeground As B4XView
    Private ivBackground As B4XView
    Public lblStats As B4XView
    Public TileMap As X2TileMap
    Public Const ObjectLayer As String = "Object Layer 1"
    Public RightDown, LeftDown, JumpDown, DownDown, UpDown As Boolean
End Sub
Public Sub Initialize (Parent As B4XView)
    Parent.LoadLayout("1")
    world.Initialize("world", world.CreateVec2(0, -20))
    X2.Initialize(Me, ivForeground, world)
    Dim WorldHeight As Float = 14 'the size of each tile will be approximately 1x1 meter
    Dim WorldWidth As Float = WorldHeight * 1.3333
    X2.ConfigureDimensions(world.CreateVec2(WorldWidth / 2, WorldHeight / 2), WorldWidth)
    lblStats.TextColor = xui.Color_Black
    lblStats.Color = 0x88ffffff
    lblStats.Font = xui.CreateDefaultBoldFont(20)
    'comment to disable debug drawing
    ' X2.EnableDebugDraw
    TileMap.Initialize(X2, File.DirAssets, "test.json", Null)
    TileMap.SetSingleTileDimensionsInMeters(WorldWidth / TileMap.TilesPerRow, WorldHeight / TileMap.TilesPerColumn)
    TileMap.PrepareObjectsDef(ObjectLayer)
    Dim ol As X2ObjectsLayer = TileMap.Layers.Get(ObjectLayer)
    For Each template As X2TileObjectTemplate In ol.ObjectsById.Values
        Dim bw As X2BodyWrapper = TileMap.CreateObject(template)
    Next
'    X2.SetBitmapWithFitOrFill(ivBackground, xui.LoadBitmapResize(File.DirAssets, "Sky.jpg", ivBackground.Width / 2, ivBackground.Height / 2, False))
    X2.Start
End Sub
Public Sub Tick (GS As X2GameStep)
    TileMap.DrawScreen(Array("Tile Layer 1"),GS.DrawingTasks)
End Sub
Public Sub DrawingComplete
    TileMap.DrawingComplete()
End Sub