@@ -53,15 +53,15 @@ type Firefly struct {
5353 SpriteSheet util.AnimatedSheet
5454 SpriteSheetRev util.AnimatedSheet
5555
56- Pos util. Vec2
56+ Pos ffmath. Vec
5757 Angle firefly.Angle
5858 SpeedFactor float32
5959
6060 MoveSpeed float32
6161 Nimbleness float32
6262}
6363
64- func NewFireflyPlayer (peer firefly.Peer , stats state.Firefly , pos util. Vec2 , angle firefly.Angle ) Firefly {
64+ func NewFireflyPlayer (peer firefly.Peer , stats state.Firefly , pos ffmath. Vec , angle firefly.Angle ) Firefly {
6565 return Firefly {
6666 IsPlayer : true ,
6767 Peer : peer ,
@@ -75,10 +75,10 @@ func NewFireflyPlayer(peer firefly.Peer, stats state.Firefly, pos util.Vec2, ang
7575 }
7676}
7777
78- func NewFireflyBot (pos util. Vec2 , angle firefly.Angle ) Firefly {
78+ func NewFireflyBot (pos ffmath. Vec , angle firefly.Angle ) Firefly {
7979 // Randomize skills
8080 // These skills must be better than the starting score when buying a basic firefly
81- speed := 12 + ffrand .Intn ( 18 - 12 )
81+ speed := ffrand .IntRange ( 12 , 18 )
8282 nimbleness := 12 + (18 - speed )
8383 return Firefly {
8484 IsPlayer : false ,
@@ -100,7 +100,7 @@ func (f *Firefly) Update() PathTrackerResult {
100100 } else {
101101 f .updateBotInput ()
102102 }
103- dir := util . AngleToVec2 (f .Angle )
103+ dir := ffmath . VAngle (f .Angle )
104104 newPos := f .Pos .Add (dir .Scale (f .MoveSpeed * f .SpeedFactor * StatsMoveSpeedFactor ))
105105 f .Move (newPos )
106106 trackerResult := f .PathTracker .Update (f .Pos )
@@ -111,7 +111,7 @@ func (f *Firefly) Update() PathTrackerResult {
111111 return trackerResult
112112}
113113
114- func (f * Firefly ) Move (to util. Vec2 ) {
114+ func (f * Firefly ) Move (to ffmath. Vec ) {
115115 delta := to .Sub (f .Pos )
116116 if delta .RadiusSquared () <= 0.01 {
117117 // no need to move
@@ -194,7 +194,7 @@ func (f *Firefly) Render(scene *Scene) {
194194 // Draw arrow to direction you should move in
195195 targetPoint := f .PathTracker .PeekSoftNext (f .Pos )
196196 targetAngle := targetPoint .Sub (f .Pos ).Azimuth ()
197- targetDir := util . AngleToVec2 (targetAngle )
197+ targetDir := ffmath . VAngle (targetAngle )
198198 drawArrow (
199199 point .Add (targetDir .Scale (10 ).Point ()),
200200 targetAngle ,
@@ -212,20 +212,20 @@ func (f *Firefly) Render(scene *Scene) {
212212}
213213
214214func drawArrow (from firefly.Point , angle firefly.Angle , length int , lineStyle firefly.LineStyle ) {
215- fromV := util . PointToVec2 (from )
216- toV := fromV .Add (util . AngleToVec2 (angle ).Scale (float32 (length )))
215+ fromV := ffmath . VPoint (from )
216+ toV := fromV .Add (ffmath . VAngle (angle ).Scale (float32 (length )))
217217 to := toV .Point ()
218218 firefly .DrawLine (
219219 from ,
220220 to ,
221221 lineStyle )
222222 firefly .DrawLine (
223223 to ,
224- toV .Add (util . AngleToVec2 (angle .Add (firefly .Degrees (145 ))).Scale (3 )).Point (),
224+ toV .Add (ffmath . VAngle (angle .Add (firefly .Degrees (145 ))).Scale (3 )).Point (),
225225 lineStyle )
226226 firefly .DrawLine (
227227 to ,
228- toV .Add (util . AngleToVec2 (angle .Add (firefly .Degrees (- 145 ))).Scale (3 )).Point (),
228+ toV .Add (ffmath . VAngle (angle .Add (firefly .Degrees (- 145 ))).Scale (3 )).Point (),
229229 lineStyle )
230230}
231231
0 commit comments