Tons of experimental updates.

This commit is contained in:
2023-10-27 09:59:01 -04:00
parent 8fd27c5df7
commit 1ffc593ebe
11 changed files with 625 additions and 0 deletions

51
character/character.go Normal file
View File

@@ -0,0 +1,51 @@
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...)
}