trying to visualize bot direction
This commit is contained in:
parent
bb072255cd
commit
f06ccd2588
27
spectator.go
27
spectator.go
@ -9,12 +9,10 @@ import (
|
||||
"bitbucket.org/hackerbots/server"
|
||||
)
|
||||
|
||||
var bots = []rune{
|
||||
'。', 'ヲ', 'ァ', 'ィ', 'ゥ', 'ェ', 'ォ', 'ャ', 'ュ', 'ョ', 'ッ', 'ー', 'ア', 'イ', 'ウ',
|
||||
'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ', 'シ', 'ス', 'セ', 'ソ', 'タ', 'チ', 'ツ',
|
||||
'テ', 'ト', 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ', 'マ', 'ミ', 'ム',
|
||||
'メ', 'モ', 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', 'ル', 'レ', 'ロ', 'ワ', 'ン', '゙', '゚',
|
||||
}
|
||||
var botDown rune = 'v'
|
||||
var botUp rune = '^'
|
||||
var botRight rune = '>'
|
||||
var botLeft rune = '<'
|
||||
|
||||
type size struct {
|
||||
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))
|
||||
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
|
||||
if bot.Health < 0 {
|
||||
c = termbox.ColorBlack
|
||||
|
Loading…
Reference in New Issue
Block a user