From 8a85c94767a505cebeb1d78a59766b5ef311c98d Mon Sep 17 00:00:00 2001 From: stephen mcquay Date: Mon, 31 Aug 2015 21:59:21 -0700 Subject: [PATCH] draw own bot last --- spectator.go | 58 ++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/spectator.go b/spectator.go index 6d2fd87..24075a4 100644 --- a/spectator.go +++ b/spectator.go @@ -85,35 +85,6 @@ func (s *Client) Visualize() { } } - for _, bot := range u.MyRobots { - x := int((bot.Position.X / s.width) * float64(s.viewX)) - y := int((bot.Position.Y / s.height) * float64(s.viewY)) - var b rune - if math.Abs(bot.Heading.X) > math.Abs(bot.Heading.Y) { - if bot.Heading.X > 0 { - b = botRight - } else { - b = botLeft - } - } else { - if bot.Heading.Y > 0 { - b = botUp - } else { - b = botDown - } - } - c := termbox.ColorWhite - if bot.Health <= 0 { - c = termbox.ColorBlack - } - termbox.SetCell( - x, - s.viewY-y, - b, - c|termbox.AttrBold, termbox.ColorBlack, - ) - } - for _, bot := range u.OtherRobots { x := int((bot.Position.X / s.width) * float64(s.viewX)) y := int((bot.Position.Y / s.height) * float64(s.viewY)) @@ -178,6 +149,35 @@ func (s *Client) Visualize() { } } + for _, bot := range u.MyRobots { + x := int((bot.Position.X / s.width) * float64(s.viewX)) + y := int((bot.Position.Y / s.height) * float64(s.viewY)) + var b rune + if math.Abs(bot.Heading.X) > math.Abs(bot.Heading.Y) { + if bot.Heading.X > 0 { + b = botRight + } else { + b = botLeft + } + } else { + if bot.Heading.Y > 0 { + b = botUp + } else { + b = botDown + } + } + c := termbox.ColorWhite + if bot.Health <= 0 { + c = termbox.ColorBlack + } + termbox.SetCell( + x, + s.viewY-y, + b, + c|termbox.AttrBold, termbox.ColorBlack, + ) + } + err := termbox.Flush() if err != nil { panic(err)