diff --git a/cmd/rove/main.go b/cmd/rove/main.go index 398feb9..17e35aa 100644 --- a/cmd/rove/main.go +++ b/cmd/rove/main.go @@ -4,13 +4,16 @@ import ( "encoding/json" "fmt" "io/ioutil" + "math" "os" "path" "path/filepath" "time" + "github.com/mdiluz/rove/pkg/atlas" "github.com/mdiluz/rove/pkg/bearing" "github.com/mdiluz/rove/pkg/game" + "github.com/mdiluz/rove/pkg/objects" "github.com/mdiluz/rove/pkg/rove" "github.com/mdiluz/rove/pkg/version" "golang.org/x/net/context" @@ -253,8 +256,24 @@ func InnerMain(command string, args ...string) error { return err default: + // Print out the radar - game.PrintTiles(response.Tiles) + num := int(math.Sqrt(float64(len(response.Tiles)))) + for j := num - 1; j >= 0; j-- { + for i := 0; i < num; i++ { + t := response.Tiles[i+num*j] + o := response.Objects[i+num*j] + if o != byte(objects.None) { + fmt.Printf("%c", o) + } else if t != byte(atlas.TileNone) { + fmt.Printf("%c", t) + } else { + fmt.Printf(" ") + } + + } + fmt.Print("\n") + } } case "rover": diff --git a/pkg/game/world.go b/pkg/game/world.go index 59d004d..a0809ed 100644 --- a/pkg/game/world.go +++ b/pkg/game/world.go @@ -4,7 +4,6 @@ import ( "bufio" "fmt" "log" - "math" "math/rand" "os" "sync" @@ -425,24 +424,6 @@ func (w *World) ExecuteCommand(c *Command, rover string) (err error) { return } -// PrintTiles simply prints the input tiles directly for debug -func PrintTiles(tiles []byte) { - num := int(math.Sqrt(float64(len(tiles)))) - for j := num - 1; j >= 0; j-- { - for i := 0; i < num; i++ { - - t := tiles[i+num*j] - if t != 0 { - fmt.Printf("%c", t) - } else { - fmt.Printf(" ") - } - - } - fmt.Print("\n") - } -} - // RLock read locks the world func (w *World) RLock() { w.worldMutex.RLock()