This commit is contained in:
@@ -69,11 +69,16 @@ func (a *Animation) updateMarioPosition() {
|
|||||||
marioY += centerY
|
marioY += centerY
|
||||||
|
|
||||||
// Check for edge collision and change direction if necessary
|
// Check for edge collision and change direction if necessary
|
||||||
if marioX < 0 || marioX >= a.ctx.Width() {
|
if marioX < 0 {
|
||||||
a.mario.angle = -a.mario.angle
|
a.mario.angle = -a.mario.angle + math.Pi // Reflect horizontally and adjust angle
|
||||||
|
} else if marioX >= a.ctx.Width() {
|
||||||
|
a.mario.angle = -a.mario.angle + math.Pi // Reflect horizontally and adjust angle
|
||||||
}
|
}
|
||||||
if marioY < 0 || marioY >= a.ctx.Height() {
|
|
||||||
a.mario.angle = math.Pi + (math.Pi - a.mario.angle)
|
if marioY < 0 {
|
||||||
|
a.mario.angle = math.Pi - a.mario.angle // Flip vertically and adjust angle
|
||||||
|
} else if marioY >= a.ctx.Height() {
|
||||||
|
a.mario.angle = math.Pi - a.mario.angle // Flip vertically and adjust angle
|
||||||
}
|
}
|
||||||
|
|
||||||
a.mario.position.X = marioX
|
a.mario.position.X = marioX
|
||||||
|
|||||||
Reference in New Issue
Block a user