updated the collision for jumps and terrain

This commit is contained in:
phenom
2026-08-16 18:07:34 -04:00
parent c00f3211ea
commit e39aebf3a1
5 changed files with 138 additions and 18 deletions
+37
View File
@@ -1,13 +1,16 @@
import { describe, expect, it } from "vitest";
import {
PLAYER_GROUND_MIN_NORMAL_Y,
PLAYER_AIRBORNE_PRESENTATION_DELAY_MS,
PLAYER_JUMP_BUFFER_MS,
PLAYER_JUMP_COYOTE_MS,
bufferPlayerJump,
cancelBufferedPlayerJump,
characterVerticalMotion,
createCharacterVerticalPresentationTiming,
createPlayerJumpTiming,
isWalkableGroundHit,
updateCharacterVerticalPresentation,
updatePlayerJumpTiming,
} from "./playerJump";
@@ -63,4 +66,38 @@ describe("player jump timing", () => {
expect(characterVerticalMotion(true, 0, 100, 150)).toBe("landing");
expect(characterVerticalMotion(true, 0, 150, 150)).toBe("grounded");
});
it("hides brief terrain gaps without playing a landing animation", () => {
const timing = createCharacterVerticalPresentationTiming();
expect(updateCharacterVerticalPresentation(timing, false, -0.1, 1_000, false))
.toBe("grounded");
expect(updateCharacterVerticalPresentation(
timing,
true,
0,
1_000 + PLAYER_AIRBORNE_PRESENTATION_DELAY_MS - 1,
false,
)).toBe("grounded");
});
it("presents real falls and intentional jumps, then lands once", () => {
const falling = createCharacterVerticalPresentationTiming();
expect(updateCharacterVerticalPresentation(falling, false, -1, 2_000, false))
.toBe("grounded");
expect(updateCharacterVerticalPresentation(
falling,
false,
-2,
2_000 + PLAYER_AIRBORNE_PRESENTATION_DELAY_MS,
false,
)).toBe("falling");
expect(updateCharacterVerticalPresentation(falling, true, 0, 2_200, false))
.toBe("landing");
expect(updateCharacterVerticalPresentation(falling, true, 0, 2_400, false))
.toBe("grounded");
const jumping = createCharacterVerticalPresentationTiming();
expect(updateCharacterVerticalPresentation(jumping, false, 7.2, 3_000, true))
.toBe("rising");
});
});