shallower ellipses
All checks were successful
build rgb-board / build (push) Successful in 3m58s

This commit is contained in:
Nathan Wagner
2025-06-12 14:11:44 +00:00
parent 6d1cd08949
commit ded945e7b9
2 changed files with 13 additions and 6 deletions

View File

@@ -68,6 +68,14 @@ func (a *Animation) updateMarioPosition() {
marioX += centerX
marioY += centerY
// Check for edge collision and change direction if necessary
if marioX < 0 || marioX >= a.ctx.Width() {
a.mario.angle = -a.mario.angle
}
if marioY < 0 || marioY >= a.ctx.Height() {
a.mario.angle = math.Pi + (math.Pi - a.mario.angle)
}
a.mario.position.X = marioX
a.mario.position.Y = marioY
@@ -77,16 +85,15 @@ func (a *Animation) updateMarioPosition() {
a.mario.angle -= 2 * math.Pi
}
// Direction logic
// Direction logic for up and down movement
if math.Sin(t) > 0 {
a.mario.dir.X = -1 // Moving left
} else {
a.mario.dir.X = 1 // Moving right
}
if math.Cos(t) > 0 {
a.mario.updown = "marioUp" // Moving downward
a.mario.updown = "marioDown" // Moving downward
} else {
a.mario.updown = "marioDown" // Moving upward
a.mario.updown = "marioUp" // Moving upward
}
}