Adding PlayerMovement class to interpolate/extrapolate position along tests (installing Jasmine)
This commit is contained in:
parent
077b29bfbd
commit
d69ce8a6a6
9 changed files with 144 additions and 2 deletions
40
front/tests/Phaser/Game/PlayerMovementTest.ts
Normal file
40
front/tests/Phaser/Game/PlayerMovementTest.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import "jasmine";
|
||||
import {PlayerMovement} from "../../../src/Phaser/Game/PlayerMovement";
|
||||
|
||||
describe("Interpolation / Extrapolation", () => {
|
||||
it("should interpolate", () => {
|
||||
let playerMovement = new PlayerMovement({
|
||||
x: 100, y: 200, moving: true, direction: "right"
|
||||
}, 42000,
|
||||
{
|
||||
x: 200, y: 100, moving: true, direction: "up"
|
||||
},
|
||||
42200
|
||||
);
|
||||
|
||||
|
||||
expect(playerMovement.isOutdated(42100)).toBe(false);
|
||||
expect(playerMovement.isOutdated(43000)).toBe(true);
|
||||
|
||||
expect(playerMovement.getPosition(42100)).toEqual({
|
||||
x: 150,
|
||||
y: 150,
|
||||
direction: 'up',
|
||||
moving: true
|
||||
});
|
||||
|
||||
expect(playerMovement.getPosition(42200)).toEqual({
|
||||
x: 200,
|
||||
y: 100,
|
||||
direction: 'up',
|
||||
moving: true
|
||||
});
|
||||
|
||||
expect(playerMovement.getPosition(42300)).toEqual({
|
||||
x: 250,
|
||||
y: 50,
|
||||
direction: 'up',
|
||||
moving: true
|
||||
});
|
||||
});
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue