Add Glyph methods to convert to a glyph

This commit is contained in:
Marc Di Luzio 2020-07-19 11:50:19 +01:00
parent 53d6ad08d9
commit acdd019093
2 changed files with 38 additions and 0 deletions

View file

@ -1,5 +1,7 @@
package atlas
import "log"
// ObjectType represents an object type
type ObjectType byte
@ -18,6 +20,23 @@ const (
ObjectLargeRock = ObjectType(GlyphLargeRock)
)
// Glyph returns the glyph for this object type
func (o ObjectType) Glyph() Glyph {
switch o {
case ObjectNone:
return GlyphNone
case ObjectRover:
return GlyphRover
case ObjectSmallRock:
return GlyphSmallRock
case ObjectLargeRock:
return GlyphLargeRock
}
log.Fatalf("Unknown object type: %c", o)
return GlyphNone
}
// Object represents an object in the world
type Object struct {
// The type of the object