From 816c603b03f037fecde9168daccaa5bd344d4c0d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 7 Oct 2014 16:37:26 -0400 Subject: nomenclature for addressing floors, ceilings --- .../javascripts/rectangles/engine/rooms/grouper.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'public/assets/javascripts/rectangles/engine/rooms/grouper.js') diff --git a/public/assets/javascripts/rectangles/engine/rooms/grouper.js b/public/assets/javascripts/rectangles/engine/rooms/grouper.js index 663d29d..ec776a2 100644 --- a/public/assets/javascripts/rectangles/engine/rooms/grouper.js +++ b/public/assets/javascripts/rectangles/engine/rooms/grouper.js @@ -48,13 +48,16 @@ base.build = function (){ var walls = [] + var floors = [] var collections = base.collect() base.cull(collections) base.group(walls, collections, FRONT) base.group(walls, collections, BACK) base.group(walls, collections, LEFT) base.group(walls, collections, RIGHT) + base.groupFloors(floors, collections) Walls.assign( walls ) + Walls.assignFloors( floors ) Walls.bind() } base.collect = function(){ @@ -63,12 +66,16 @@ collections[BACK] = [] collections[LEFT] = [] collections[RIGHT] = [] + collections[FLOOR] = [] + collections[CEILING] = [] Rooms.forEach(function(room){ room.mx_walls.forEach(function(mx){ var side = mx.side || mx.half_side collections[side].push(mx) }) + collections[FLOOR] = collections[FLOOR].concat( room.mx_floor ) + collections[CEILING] = collections[CEILING].concat( room.mx_ceiling ) }) base.cull(collections) @@ -161,6 +168,18 @@ return walls } + base.groupFloors = function(floors, collections){ + var floor = new Floor ({ + id: 'floor', + mx: collections[FLOOR] + }) + var ceiling = new Floor ({ + id: 'ceiling', + mx: collections[CEILING] + }) + floors.push(floor) + floors.push(ceiling) + } } -- cgit v1.2.3-70-g09d2 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/rectangles/engine/rooms/grouper.js') 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