trying to visualize bot direction

This commit is contained in:
Stephen McQuay 2014-05-12 22:25:44 -07:00
parent bb072255cd
commit f06ccd2588

View File

@ -9,12 +9,10 @@ import (
"bitbucket.org/hackerbots/server" "bitbucket.org/hackerbots/server"
) )
var bots = []rune{ var botDown rune = 'v'
'。', 'ヲ', 'ァ', 'ィ', 'ゥ', 'ェ', 'ォ', 'ャ', 'ュ', 'ョ', 'ッ', 'ー', 'ア', 'イ', 'ウ', var botUp rune = '^'
'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ', 'シ', 'ス', 'セ', 'ソ', 'タ', 'チ', 'ツ', var botRight rune = '>'
'テ', 'ト', 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ', 'マ', 'ミ', 'ム', var botLeft rune = '<'
'メ', 'モ', 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', 'ル', 'レ', 'ロ', 'ワ', 'ン', '゙', '゚',
}
type size struct { type size struct {
width, height int width, height int
@ -103,10 +101,23 @@ func (s *SimpleSpectator) Run() {
} }
} }
for i, 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))
b := bots[i%len(bots)] 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 c := termbox.ColorWhite
if bot.Health < 0 { if bot.Health < 0 {
c = termbox.ColorBlack c = termbox.ColorBlack