tilemap

command
v0.0.0-...-f174bb4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2016 License: MIT Imports: 4 Imported by: 0

README

TileMap Demo

What does it do?

It demonstrates how one can load and render a TMX file created from the TileMap Editor

What are important aspects of the code?

These lines are key in this demo:

  • 'resource, err := engo.Files.Resource("example.tmx")' to retrieve the resource
  • 'tmxResource := resource.(common.TMXResource)'to cast the resource to a tmx resource
  • 'levelData := tmxResource.Level' to retrieve the level from the tmx resource

Add render and space components to each tile

tileComponents := make([]*Tile, 0) 
    for _, v := range levelData.Tiles {
        if v.Image != nil {
                tile := &Tile{BasicEntity: ecs.NewBasic()}
                tile.RenderComponent = common.RenderComponent{
                        Drawable: v,
                        Scale:    engo.Point{1, 1},
                }
                tile.SpaceComponent = common.SpaceComponent{
                        Position: v.Point,
                        Width:    0,
                        Height:   0,
                }
                tileComponents = append(tileComponents, tile)
        }
    }

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL