-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCollisionJS.html
57 lines (35 loc) · 1.08 KB
/
CollisionJS.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html>
<body>
<p id="results"></p>
<p id="listResults"></p>
<script src="Actors.js"></script>
<script src="Collision.js"></script>
<script>
var LEFT = 0;
var RIGHT = 1;
var TOP = 2;
var BOT = 3;
var result = new String();
var data = [10, 10, 15, 5, 7];
result += testCollision(data) + "<br>";
data = [100, 100, 50, 50, 7];
result += testCollision(data) + "<br>";
document.getElementById("results").innerHTML = result;
var point = [10, 10];
var radius = 7;
var testPoints = [[100, 100], [150, 150], [10,20], [25, 10], [15, 30]];
var listResult = new String();
listResult += testCollisionList(point, testPoints, radius) + "<br>";
testPoints.push([5, 5]);
listResult += testCollisionList(point, testPoints, radius) + "<br>";
document.getElementById("listResults").innerHTML = listResult;
function testCollisionList(point, list, r) {
return list.toString() + " " + didCollideWithAnyPoint(point[0], point[1], list, r);
}
function testCollision(data) {
return data.toString() + " "+ didCollide(data[0], data[1], data[2], data[3], data[4]);
}
</script>
</body>
</html>