Games [XUI2D] Single Screen Tile Map Example / Hello World With Background

Discussion in 'Game Development' started by Erel, Sep 27, 2018.

  1. Erel

    Erel Administrator Staff Member Licensed User


    This example shows how to use X2TileMap to create a single screen game with tiles based background. This means that the background is never scrolled.

    To avoid drawing issues we want that the size of each tile will be a whole number and that each tile will be square shaped.

    This is done with:
    Dim TileSize As Int = Min(X2.MainBC.mWidth / TileMap.TilesPerRow, X2.MainBC.mHeight / TileMap.TilesPerColumn)
    TileMap.SetSingleTileDimensionsInBCPixels(TileSize, TileSize)
    Private Sub SetWorldCenter
    'The map size will not be identical to the screen size. This happens because the tile size in (bc) pixels needs to be a whole number.
       'So we need to update the world center and move the map to the center.
    End Sub
    Drawing a tiles map is done with:
    Public Sub Tick (GS As X2GameStep)
    Array("Tile Layer 1"), GS.DrawingTasks)
    End Sub

    Public Sub DrawingComplete
    End Sub
    The example is included in the examples pack.
    TnP, naifnas, Procesor and 5 others like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice