package main
import "image/color"
const TileTime = 0.35
type Crew struct {
ID int
Name string
Initial rune
Color color.RGBA
TileX int
TileY int
Path [][2]int
MoveT float64
}
func NewStartingCrew() []Crew {
return []Crew{
{ID: 1, Name: "Alice", Initial: 'A', Color: color.RGBA{R: 80, G: 180, B: 170, A: 255}, TileX: 4, TileY: 10},
{ID: 2, Name: "Bob", Initial: 'B', Color: color.RGBA{R: 220, G: 170, B: 80, A: 255}, TileX: 7, TileY: 10},
{ID: 3, Name: "Carol", Initial: 'C', Color: color.RGBA{R: 200, G: 100, B: 170, A: 255}, TileX: 11, TileY: 10},
}
}
func updateCrew(c *Crew, dt float64) {
if len(c.Path) == 0 {
return
}
c.MoveT += dt / TileTime
for c.MoveT >= 1 && len(c.Path) > 0 {
c.TileX, c.TileY = c.Path[0][0], c.Path[0][1]
c.Path = c.Path[1:]
c.MoveT -= 1
}
if len(c.Path) == 0 {
c.MoveT = 0
}
}