From 8e92059e543d85324d2b6d175fc1143de658e90f Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Thu, 1 May 2025 04:32:41 +0000 Subject: [PATCH] more vibing man --- animationMario.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/animationMario.go b/animationMario.go index 51845f2..66f462d 100644 --- a/animationMario.go +++ b/animationMario.go @@ -75,11 +75,12 @@ func (a *Animation) updateMarioPosition() { amplitude = 4 // Amplitude of the sine wave ) - currentTime := float64(a.ctx.Width()) / wavelength // Calculate current time based on position + currentTime := float64(a.mario.position.X) / wavelength // Calculate current time based on Mario's X position a.mario.position.X += int(amplitude*math.Sin(2*math.Pi*currentTime/wavelength)) + a.mario.dir.X a.mario.position.Y += a.mario.dir.Y + // Ensure Mario stays within the display boundaries and reverses direction when necessary. if a.mario.position.Y+a.height > a.ctx.Height() { a.mario.position.Y = a.ctx.Height() - a.height // Reset Y position to the top boundary a.mario.updown = "marioUp" @@ -91,10 +92,8 @@ func (a *Animation) updateMarioPosition() { } if a.mario.position.X+a.width > a.ctx.Width() { - a.mario.position.X = a.ctx.Width() - a.width // Reset X position to the left boundary - a.mario.dir.X = -a.mario.dir.X // Reverse direction when hitting right edge + a.mario.position.X -= (a.mario.position.X + a.width - a.ctx.Width()) // Wrap around to the left side } else if a.mario.position.X < 0 { - a.mario.position.X = 0 // Reset X position to the right boundary - a.mario.dir.X = -a.mario.dir.X // Reverse direction when hitting left edge + a.mario.position.X = -(a.mario.position.X) // Wrap around to the right side } }