From 646b9a935b4fbcc7b0108a66fe7309a61c55d3c1 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 7 Oct 2014 16:52:43 -0400 Subject: tiling wallpaper on ceiling / floor --- .../javascripts/rectangles/engine/rooms/grouper.js | 2 ++ public/assets/javascripts/rectangles/models/floor.js | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'public/assets/javascripts') 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) { -- cgit v1.2.3-70-g09d2