draw own bot last

This commit is contained in:
Stephen McQuay 2015-08-31 21:59:21 -07:00
parent 623dfa4c48
commit 8a85c94767
1 changed files with 29 additions and 29 deletions

View File

@ -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 { for _, bot := range u.OtherRobots {
x := int((bot.Position.X / s.width) * float64(s.viewX)) x := int((bot.Position.X / s.width) * float64(s.viewX))
y := int((bot.Position.Y / s.height) * float64(s.viewY)) 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() err := termbox.Flush()
if err != nil { if err != nil {
panic(err) panic(err)