blob: fa0a29e9b4c84ce9c060d874e04f5566b9161ec0 (
plain)
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
|
'use strict';
var CollisionMap = function() {
this.map = [];
};
CollisionMap.prototype = {
addToMap: function(x, y) {
if (!this.map) {
this.map = [];
}
if (!this.map[x]) {
this.map[x] = [];
}
this.map[x][y] = true;
},
removeFromMap: function(x,y) {
if (!this.map || !this.map[x]) {
return;
}
this.map[x][y] = false;
},
checkMap: function(x,y) {
if (!this.map || !this.map[x]) {
return false;
}
return !!this.map[x][y];
}
}
module.exports = CollisionMap;
|