rove/pkg/atlas/atlas.go

38 lines
878 B
Go
Raw Normal View History

package atlas
import (
"log"
2020-07-10 18:22:59 +01:00
"github.com/mdiluz/rove/pkg/maths"
"github.com/mdiluz/rove/proto/roveapi"
)
// TileGlyph returns the glyph for this tile type
func TileGlyph(t roveapi.Tile) Glyph {
switch t {
case roveapi.Tile_TileNone:
return GlyphNone
case roveapi.Tile_Rock:
2020-07-19 11:56:05 +01:00
return GlyphGroundRock
case roveapi.Tile_Gravel:
2020-07-19 11:56:05 +01:00
return GlyphGroundGravel
case roveapi.Tile_Sand:
2020-07-19 11:56:05 +01:00
return GlyphGroundSand
}
log.Fatalf("Unknown tile type: %c", t)
return GlyphNone
}
2020-07-10 16:52:00 +01:00
// Atlas represents a 2D world atlas of tiles and objects
type Atlas interface {
// SetTile sets a location on the Atlas to a type of tile
SetTile(v maths.Vector, tile roveapi.Tile)
2020-07-10 16:52:00 +01:00
// SetObject will set a location on the Atlas to contain an object
2020-07-10 18:39:33 +01:00
SetObject(v maths.Vector, obj Object)
2020-07-10 16:52:00 +01:00
// QueryPosition queries a position on the atlas
QueryPosition(v maths.Vector) (roveapi.Tile, Object)
2020-07-10 16:52:00 +01:00
}