package character import ( "image/color" p "loading/point" "math" "math/rand" "strconv" ) const ( agentIdMax = 100 offset = 15 xd = offset yd = offset ) type Character struct { Name string Pose p.Point Shape []p.Point Color color.RGBA Angle float32 DeltaAngle float32 SignFlip float32 Buffer float32 } func NewCharacter() Character { return Character{ Name: "Agent-" + strconv.Itoa(rand.Intn(agentIdMax)), Pose: p.Point{X: 0, Y: 0}, Shape: []p.Point{{X: 0, Y: 0}, {X: xd, Y: 0}, {X: xd, Y: yd}}, Color: color.RGBA{0xFF, 0xFF, 0xFF, 0xFF}, Angle: (rand.Float32() * 2 * math.Pi), DeltaAngle: 0, Buffer: offset, } } func (c *Character) SetPose(x float32, y float32) { c.Pose.X = x c.Pose.Y = y } func (c *Character) LoadShape(vertices []p.Point) { c.Shape = c.Shape[:0] c.Shape = append(c.Shape, vertices...) }