From 2f23271bf113b3952ff9d24549aefa9abfb4f926 Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Thu, 12 Jun 2025 13:34:31 +0000 Subject: [PATCH] give this another shot --- animationMario.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/animationMario.go b/animationMario.go index 68bed56..18cc1a1 100644 --- a/animationMario.go +++ b/animationMario.go @@ -56,38 +56,37 @@ func (a *Animation) animateMario() { } } -// what mario does every frame func (a *Animation) updateMarioPosition() { - // Ellipse parameters (centered on canvas) centerX := a.ctx.Width() / 2 centerY := a.ctx.Height() / 2 - // Calculate new position using parametric ellipse equations t := a.mario.angle - marioX := int(float64(centerX) + math.Round(a.mario.a*math.Cos(t))) - marioY := int(float64(centerY) + math.Round(a.mario.b*math.Sin(t))) + marioX := int(math.Round(float64(a.mario.a * math.Cos(t)))) + marioY := int(math.Round(float64(a.mario.b * math.Sin(t)))) + + // Adjust position relative to the center of the panel + marioX += centerX + marioY += centerY + + a.mario.position.X = marioX + a.mario.position.Y = marioY // Update angle to move along the ellipse - a.mario.angle += 0.1 // Adjust speed as needed + a.mario.angle += 0.1 if a.mario.angle >= 2*math.Pi { a.mario.angle -= 2 * math.Pi } - // Determine horizontal direction (left/right) for image flipping + // Direction logic if math.Sin(t) > 0 { a.mario.dir.X = -1 // Moving left } else { a.mario.dir.X = 1 // Moving right } - // Determine vertical direction (up/down) for image selection if math.Cos(t) > 0 { a.mario.updown = "marioUp" // Moving downward } else { a.mario.updown = "marioDown" // Moving upward } - - // Update Mario's position - a.mario.position.X = marioX - a.mario.position.Y = marioY }