summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/models/wall.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/rectangles/models/wall.js')
-rw-r--r--public/assets/javascripts/rectangles/models/wall.js37
1 files changed, 25 insertions, 12 deletions
diff --git a/public/assets/javascripts/rectangles/models/wall.js b/public/assets/javascripts/rectangles/models/wall.js
index 027d5f5..f2b8bca 100644
--- a/public/assets/javascripts/rectangles/models/wall.js
+++ b/public/assets/javascripts/rectangles/models/wall.js
@@ -1,21 +1,31 @@
-window.Wall = (function(){
+(function(){
+ var vec2, Rect, sort
+ if ('window' in this) {
+ vec2 = window.vec2
+ Rect = window.Rect
+ sort = window.sort
+ }
+ else {
+ vec2 = require('./vec2')
+ Rect = require('./rect')
+ UidGenerator = require('../util/uid')
+ }
+ var wall_uid = new UidGenerator({})
+
var Wall = function(opt){
this.id = opt.id
- this.uid = Uid()
- this.room = opt.room
- this.rect = opt.rect || new Rect (0,0,0,0)
- this.rect.sides = opt.side
+ this.uid = wall_uid
+ this.vec = opt.vec
this.side = opt.side
this.mx = []
- this.els = []
if (opt.el) {
this.mx.push(opt.el)
}
}
Wall.prototype.toString = function(){
- return this.rect.toString()
+ return this.vec.toString()
}
Wall.prototype.reset = function(){
@@ -25,7 +35,7 @@ window.Wall = (function(){
this.mx.forEach(function(mx){
mx.destroy && mx.destroy()
})
- this.room = this.rect = this.mx = this.els = null
+ this.room = this.vec = this.mx = null
}
Wall.prototype.bind = function(){
@@ -146,8 +156,6 @@ window.Wall = (function(){
if (shouldFlip) {
sortedWalls = sortedWalls.reverse()
}
-
-console.log(sortedWalls.map(function(z){return useX ? z.x : z.z}).join(" "))
var len = sortedWalls.length
@@ -184,7 +192,6 @@ console.log(sortedWalls.map(function(z){return useX ? z.x : z.z}).join(" "))
mx.el.style.backgroundImage = "url(" + dataUrl + ")"
})
- window.zz += 1
}
Wall.prototype.siblings = function(){
@@ -222,6 +229,12 @@ console.log(sortedWalls.map(function(z){return useX ? z.x : z.z}).join(" "))
})
}
- return Wall
+ if ('window' in this) {
+ window.Wall = Wall
+ }
+ else {
+ module.exports = Wall
+ }
+
})()