summaryrefslogtreecommitdiff
path: root/game/entities/collisionMap.js
diff options
context:
space:
mode:
Diffstat (limited to 'game/entities/collisionMap.js')
-rw-r--r--game/entities/collisionMap.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/game/entities/collisionMap.js b/game/entities/collisionMap.js
new file mode 100644
index 0000000..fa0a29e
--- /dev/null
+++ b/game/entities/collisionMap.js
@@ -0,0 +1,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; \ No newline at end of file