summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--public/assets/javascripts/rectangles/engine/rooms/grouper.js2
-rw-r--r--public/assets/javascripts/rectangles/models/floor.js18
2 files changed, 11 insertions, 9 deletions
diff --git a/public/assets/javascripts/rectangles/engine/rooms/grouper.js b/public/assets/javascripts/rectangles/engine/rooms/grouper.js
index ec776a2..890a476 100644
--- a/public/assets/javascripts/rectangles/engine/rooms/grouper.js
+++ b/public/assets/javascripts/rectangles/engine/rooms/grouper.js
@@ -171,10 +171,12 @@
base.groupFloors = function(floors, collections){
var floor = new Floor ({
id: 'floor',
+ side: FLOOR,
mx: collections[FLOOR]
})
var ceiling = new Floor ({
id: 'ceiling',
+ side: CEILING,
mx: collections[CEILING]
})
floors.push(floor)
diff --git a/public/assets/javascripts/rectangles/models/floor.js b/public/assets/javascripts/rectangles/models/floor.js
index ee264c7..78e9019 100644
--- a/public/assets/javascripts/rectangles/models/floor.js
+++ b/public/assets/javascripts/rectangles/models/floor.js
@@ -32,11 +32,10 @@
Floor.prototype.bind = function(){
var base = this
base.$els = $( this.mx.map(function(mx){ return mx.el }) )
- console.log("HELLO")
+
this.mx.forEach(function(mx, index){
$(mx.el).bind({
mousedown: function(e){
- console.log("clicked on", base.id)
if (Scenery.nextWallpaper) {
var oldState = base.serialize()
base.wallpaper(Scenery.nextWallpaper)
@@ -119,22 +118,23 @@
var w = Math.round( this.backgroundImage.naturalWidth * this.background.scale )
var h = Math.round( this.backgroundImage.naturalHeight * this.background.scale )
- this.surface.faces.forEach(function(face, i){
+ this.mx.forEach(function(mx, i){
+
+ var region = mx.rect
if (shouldFlip) {
- mx = this.mx[this.mx.length-1-i]
- dx = Math.round( this.background.x + face.x.a )
- dy = Math.round( this.background.y + face.y.b )
+ dx = Math.round( this.background.x - region.x.a )
+ dy = Math.round( this.background.y - region.y.a )
}
else {
- mx = this.mx[i]
- dx = Math.round( this.background.x - face.x.b )
- dy = Math.round( this.background.y + face.y.b )
+ dx = Math.round( this.background.x - region.x.a )
+ dy = Math.round( this.background.y + region.y.b )
}
mx.el.style.backgroundPosition = dx + 'px ' + dy + 'px'
mx.el.style.backgroundSize = w + 'px ' + h + 'px'
}.bind(this))
+ bbb = this
}
if ('window' in this) {