-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.js
23 lines (20 loc) · 875 Bytes
/
tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
QUnit.test("Collision Tests", function(assert) {
var platform = new Platform(40, 40, 200, 20, 0, 0, false);
var player = new Player(35, 35, []);
assert.ok(player.collidesWith(platform),
"Player Collides With Platform");
platform.x = 5000;
assert.ok(!player.collidesWith(platform),
"Player Does Not Collide With Platform");
});
QUnit.test("Collision Handling Tests", function(assert) {
var platform1 = new Platform(40, 40, 20, 40, 0, 0, false);
var platform2 = new Platform(0, 40, 200, 20, 0, 0, false);
var player = new Player(35, 35, [platform1, platform2]);
console.log(player.getCollisionCandidates());
assert.ok(player.getCollisionCandidates().length > 0,
"Player Collides With Both Platforms");
player.update();
assert.ok(player.getCollisionCandidates().length === 0,
"Player Does Not Collide With Any Platforms");
});