fix: Improve rabbit collision, rotation, and jumping mechanics

This commit is contained in:
Kacper Kostka (aider)
2025-04-05 17:26:25 +02:00
parent 61ee259f6b
commit 90650fefdd
2 changed files with 28 additions and 10 deletions

View File

@@ -58,7 +58,7 @@ class Rabbit extends Entity {
while (this.isPixelSolid(this.x, newY)) {
newY--;
}
newY = Math.floor(newY) + 0.99; // Position just above ground
newY = Math.floor(newY) + 0.5; // Position just above ground (reduced from 0.99)
} else {
// Hit ceiling
this.vy = 0;
@@ -91,9 +91,16 @@ class Rabbit extends Entity {
this.vx = 0;
}
// Update sprite direction
// Update sprite direction but only flip the sprite, not rotate it
this.flipped = this.direction < 0;
// Only apply rotation when jumping
if (this.isJumping) {
this.rotation = this.direction < 0 ? -0.2 : 0.2;
} else {
this.rotation = 0;
}
return true;
}
@@ -102,10 +109,10 @@ class Rabbit extends Entity {
if (!this.isJumping && this.actionDuration <= 0) {
const decision = Math.random();
if (decision < 0.2) {
if (decision < 0.5) { // Increased from 0.2 to 0.5 for more frequent jumping
// Jump
this.jump();
} else if (decision < 0.6) {
} else if (decision < 0.8) { // Adjusted range
// Move
this.move();
} else {