diff options
Diffstat (limited to 'engine/Components/World/Descriptor.go')
| -rw-r--r-- | engine/Components/World/Descriptor.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/engine/Components/World/Descriptor.go b/engine/Components/World/Descriptor.go new file mode 100644 index 0000000..553aa5b --- /dev/null +++ b/engine/Components/World/Descriptor.go @@ -0,0 +1,29 @@ +package world + +import rl "github.com/gen2brain/raylib-go/raylib" + +type Descriptor struct { + TileSize rl.Vector2 + Textures map[int]string `json:"textures"` + WorldMap [][]TileDescriptor `json:"worldmap"` +} + +func (base *Descriptor) GenerateMap() *World { + var outp = &World { + TileSize: base.TileSize, + TextureNames: base.Textures, + Tiles: make([][]Tile, len(base.WorldMap)), + } + for x := range base.WorldMap { + outp.Tiles[x] = make([]Tile, len(base.WorldMap[x])) + for y, tile := range base.WorldMap[x] { + outp.Tiles[x][y] = &StandardTile { + X: float32(x), + Y: float32(y), + ParentWorld: outp, + Descriptor: tile, + } + } + } + return outp +} |
