Skip to content

Commit

Permalink
add new tests and fix more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
hood committed Aug 3, 2021
1 parent 84811a1 commit 095cd65
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/helpers/world/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export function slide(
_y,
w,
h,
goalX,
goalY,
_goalX,
_goalY,
filter
);

Expand Down
23 changes: 22 additions & 1 deletion test/world.new.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('World (new tests)', () => {
expect(nextPosition.y).toEqual(4);
});

it('should survive edge cases', () => {
it('should survive edge cases (walls to the R, B and BR of the moving item)', () => {
const world = Bump.newWorld(64);

const a = world.add('a', 4, 4, 4, 4);
Expand All @@ -31,4 +31,25 @@ describe('World (new tests)', () => {
expect(nextPosition2.y).toEqual(4);
expect(nextPosition2.collisions.length).toEqual(2);
});

it(`should let an item smoothly scroll horizontally even when a wall is right below of it
Illustration:
a -> *
b c d e f`, () => {
const world = Bump.newWorld(32);

const a = world.add('a', 4, 4, 4, 4);
const b = world.add('b', 0, 8, 4, 4);
const c = world.add('c', 4, 8, 4, 4);
const d = world.add('d', 8, 8, 4, 4);
const e = world.add('e', 12, 8, 4, 4);
const f = world.add('f', 16, 8, 4, 4);

const nextPosition = world.move(a, 16, 5, () => 'slide');

expect(nextPosition.x).toEqual(16);
expect(nextPosition.y).toEqual(4);
expect(nextPosition.collisions.length).toEqual(1);
});
});

0 comments on commit 095cd65

Please sign in to comment.