Move glyph functions out to the glyph file
This commit is contained in:
parent
7bdfa44fb6
commit
4a89cb9d6e
3 changed files with 36 additions and 34 deletions
|
@ -1,27 +1,10 @@
|
||||||
package atlas
|
package atlas
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
|
|
||||||
"github.com/mdiluz/rove/pkg/maths"
|
"github.com/mdiluz/rove/pkg/maths"
|
||||||
"github.com/mdiluz/rove/proto/roveapi"
|
"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_Rock:
|
|
||||||
return GlyphGroundRock
|
|
||||||
case roveapi.Tile_Gravel:
|
|
||||||
return GlyphGroundGravel
|
|
||||||
case roveapi.Tile_Sand:
|
|
||||||
return GlyphGroundSand
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Fatalf("Unknown tile type: %c", t)
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Atlas represents a 2D world atlas of tiles and objects
|
// Atlas represents a 2D world atlas of tiles and objects
|
||||||
type Atlas interface {
|
type Atlas interface {
|
||||||
// SetTile sets a location on the Atlas to a type of tile
|
// SetTile sets a location on the Atlas to a type of tile
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
package atlas
|
package atlas
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/mdiluz/rove/proto/roveapi"
|
||||||
|
)
|
||||||
|
|
||||||
// Glyph represents the text representation of something in the game
|
// Glyph represents the text representation of something in the game
|
||||||
type Glyph byte
|
type Glyph byte
|
||||||
|
|
||||||
|
@ -22,3 +28,33 @@ const (
|
||||||
// GlyphRockLarge is a large blocking rock
|
// GlyphRockLarge is a large blocking rock
|
||||||
GlyphRockLarge = Glyph('O')
|
GlyphRockLarge = Glyph('O')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TileGlyph returns the glyph for this tile type
|
||||||
|
func TileGlyph(t roveapi.Tile) Glyph {
|
||||||
|
switch t {
|
||||||
|
case roveapi.Tile_Rock:
|
||||||
|
return GlyphGroundRock
|
||||||
|
case roveapi.Tile_Gravel:
|
||||||
|
return GlyphGroundGravel
|
||||||
|
case roveapi.Tile_Sand:
|
||||||
|
return GlyphGroundSand
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Fatalf("Unknown tile type: %c", t)
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// ObjectGlyph returns the glyph for this object type
|
||||||
|
func ObjectGlyph(o roveapi.Object) Glyph {
|
||||||
|
switch o {
|
||||||
|
case roveapi.Object_RoverLive:
|
||||||
|
return GlyphRoverLive
|
||||||
|
case roveapi.Object_RockSmall:
|
||||||
|
return GlyphRockSmall
|
||||||
|
case roveapi.Object_RockLarge:
|
||||||
|
return GlyphRockLarge
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Fatalf("Unknown object type: %c", o)
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
|
@ -1,26 +1,9 @@
|
||||||
package atlas
|
package atlas
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
|
|
||||||
"github.com/mdiluz/rove/proto/roveapi"
|
"github.com/mdiluz/rove/proto/roveapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ObjectGlyph returns the glyph for this object type
|
|
||||||
func ObjectGlyph(o roveapi.Object) Glyph {
|
|
||||||
switch o {
|
|
||||||
case roveapi.Object_RoverLive:
|
|
||||||
return GlyphRoverLive
|
|
||||||
case roveapi.Object_RockSmall:
|
|
||||||
return GlyphRockSmall
|
|
||||||
case roveapi.Object_RockLarge:
|
|
||||||
return GlyphRockLarge
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Fatalf("Unknown object type: %c", o)
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Object represents an object in the world
|
// Object represents an object in the world
|
||||||
type Object struct {
|
type Object struct {
|
||||||
// The type of the object
|
// The type of the object
|
||||||
|
|
Loading…
Add table
Reference in a new issue