Skip to content
Snippets Groups Projects
Commit be5e100a authored by Julien Bouin's avatar Julien Bouin
Browse files

#6 implementation colision et tests vert

parent 0ef6220a
Branches
No related tags found
No related merge requests found
......@@ -10,4 +10,13 @@ export class Hitbox {
this.x = x;
this.y = y;
}
colision(hitbox) {
return (
this.x < hitbox.x + hitbox.width &&
this.x + this.width > hitbox.x &&
this.y < hitbox.y + hitbox.height &&
this.height + this.y > hitbox.y
);
}
}
......@@ -8,8 +8,8 @@ describe('colision', () => {
const hitbox2 = new Hitbox(100, 100, 150, 150);
assert.strictEqual(hitbox1.colision(hitbox2), true);
});
it('devrait ne pas être en colision', () => {
const hitbox1 = new Hitbox(100, 100, 0, 0);
it('devrait ne pas etre en colision', () => {
const hitbox1 = new Hitbox(100, 100, 1000, 1000);
const hitbox2 = new Hitbox(100, 100, 150, 150);
assert.strictEqual(hitbox1.colision(hitbox2), false);
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment