Popcorning Guinea Pig
Search Results for

    Show / Hide Table of Contents

    Class Tilemap

    Represents a complete tilemap loaded from a TMX file. Contains multiple layers, tilesets, and provides rendering capabilities.

    Inheritance
    object
    Tilemap
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: PopcorningGuineaPig.Engine.Gameplay
    Assembly: PopcorningGuineaPig.Engine.dll
    Syntax
    public class Tilemap

    Constructors

    | Edit this page View Source

    Tilemap(int, int, int, int)

    Creates an empty tilemap with specified dimensions.

    Declaration
    public Tilemap(int width, int height, int tileWidth, int tileHeight)
    Parameters
    Type Name Description
    int width

    Width in tiles

    int height

    Height in tiles

    int tileWidth

    Width of each tile in pixels

    int tileHeight

    Height of each tile in pixels

    Properties

    | Edit this page View Source

    Height

    Declaration
    public int Height { get; set; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    Layers

    Declaration
    public List<TilemapLayer> Layers { get; set; }
    Property Value
    Type Description
    List<TilemapLayer>
    | Edit this page View Source

    Name

    Declaration
    public string Name { get; set; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    Properties

    Declaration
    public Dictionary<string, string> Properties { get; set; }
    Property Value
    Type Description
    Dictionary<string, string>
    | Edit this page View Source

    TileHeight

    Declaration
    public int TileHeight { get; set; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    TileSize

    Declaration
    public Vector2 TileSize { get; }
    Property Value
    Type Description
    Vector2
    | Edit this page View Source

    TileWidth

    Declaration
    public int TileWidth { get; set; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    Tilesets

    Declaration
    public List<Tileset> Tilesets { get; set; }
    Property Value
    Type Description
    List<Tileset>
    | Edit this page View Source

    Width

    Declaration
    public int Width { get; set; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    WorldSize

    Declaration
    public Vector2 WorldSize { get; }
    Property Value
    Type Description
    Vector2

    Methods

    | Edit this page View Source

    CreateTileGridFromLayer(int, Vector3)

    Creates a TileGrid from a specific tilemap layer for collision detection and game logic.

    Declaration
    public TileGrid? CreateTileGridFromLayer(int layerIndex, Vector3 gridOrigin = default)
    Parameters
    Type Name Description
    int layerIndex

    Index of the layer to convert

    Vector3 gridOrigin

    Origin point for the tile grid in 3D space

    Returns
    Type Description
    TileGrid

    TileGrid populated with tiles from the tilemap layer

    | Edit this page View Source

    GetLocalTileId(int, Tileset)

    Converts a global tile ID to a local tileset tile ID.

    Declaration
    public int GetLocalTileId(int globalId, Tileset tileset)
    Parameters
    Type Name Description
    int globalId

    Global tile ID from the tilemap

    Tileset tileset

    Tileset containing the tile

    Returns
    Type Description
    int

    Local tile ID within the tileset

    | Edit this page View Source

    GetTileId(int, int, int)

    Gets the tile ID at the specified grid coordinates in a specific layer.

    Declaration
    public int GetTileId(int layerIndex, int x, int y)
    Parameters
    Type Name Description
    int layerIndex

    Layer index

    int x

    X coordinate in tiles

    int y

    Y coordinate in tiles

    Returns
    Type Description
    int

    Tile ID, or 0 if empty or out of bounds

    | Edit this page View Source

    GetTilesetForTile(int)

    Gets the tileset that contains the specified tile ID.

    Declaration
    public Tileset? GetTilesetForTile(int tileId)
    Parameters
    Type Name Description
    int tileId

    Global tile ID

    Returns
    Type Description
    Tileset

    Tileset containing the tile, or null if not found

    | Edit this page View Source

    GetWorldBounds()

    Gets the bounds of the tilemap in world coordinates.

    Declaration
    public Rectangle GetWorldBounds()
    Returns
    Type Description
    Rectangle

    Rectangle representing the tilemap bounds

    | Edit this page View Source

    TileToWorld(Vector2)

    Converts tile coordinates to world coordinates (top-left of tile).

    Declaration
    public Vector2 TileToWorld(Vector2 tilePosition)
    Parameters
    Type Name Description
    Vector2 tilePosition

    Tile coordinates

    Returns
    Type Description
    Vector2

    World position

    | Edit this page View Source

    ToString()

    Returns a string that represents the current object.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    A string that represents the current object.

    Overrides
    object.ToString()
    | Edit this page View Source

    WorldToTile(Vector2)

    Converts world coordinates to tile coordinates.

    Declaration
    public Vector2 WorldToTile(Vector2 worldPosition)
    Parameters
    Type Name Description
    Vector2 worldPosition

    World position

    Returns
    Type Description
    Vector2

    Tile coordinates

    • Edit this page
    • View Source
    In this article
    Back to top © 2024 Popcorning Guinea Pig Game Engine. A custom C# game engine for indie developers.