summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles
diff options
context:
space:
mode:
authorJulie Lala <jules@okfoc.us>2014-10-16 03:09:22 -0400
committerJulie Lala <jules@okfoc.us>2014-10-16 03:09:22 -0400
commit37851cbd12dcb17be77265164876184019d34602 (patch)
tree41d9ac3a02c62ca9421c86649672cbf19720afcd /public/assets/javascripts/rectangles
parentc13532ec95c2d410354f7d342df70fd68dd78272 (diff)
.. and floor and ceiling
Diffstat (limited to 'public/assets/javascripts/rectangles')
-rw-r--r--public/assets/javascripts/rectangles/engine/rooms/_walls.js28
-rw-r--r--public/assets/javascripts/rectangles/models/floor.js5
2 files changed, 28 insertions, 5 deletions
diff --git a/public/assets/javascripts/rectangles/engine/rooms/_walls.js b/public/assets/javascripts/rectangles/engine/rooms/_walls.js
index 5c16ce6..fe5913d 100644
--- a/public/assets/javascripts/rectangles/engine/rooms/_walls.js
+++ b/public/assets/javascripts/rectangles/engine/rooms/_walls.js
@@ -160,7 +160,19 @@
}.bind(this)
img.src = background.src
img.complete && img.onload()
- }
+ },
+ floor: function(background){
+ Walls.floors.forEach(function(floor){
+ if (floor.ceiling) return
+ floor.wallpaper(background)
+ })
+ },
+ ceiling: function(background){
+ Walls.floors.forEach(function(floor){
+ if (! floor.ceiling) return
+ floor.wallpaper(background)
+ })
+ },
}
base.clearWallpaper = {
@@ -168,7 +180,19 @@
Walls.list.forEach(function(wall){
wall.wallpaper("none")
})
- }
+ },
+ floor: function(){
+ Walls.floors.forEach(function(floor){
+ if (floor.ceiling) return
+ wall.wallpaper("none")
+ })
+ },
+ ceiling: function(){
+ Walls.floors.forEach(function(floor){
+ if (! floor.ceiling) return
+ wall.wallpaper("none")
+ })
+ },
}
base.setColor = {
diff --git a/public/assets/javascripts/rectangles/models/floor.js b/public/assets/javascripts/rectangles/models/floor.js
index 7ed52a1..9838232 100644
--- a/public/assets/javascripts/rectangles/models/floor.js
+++ b/public/assets/javascripts/rectangles/models/floor.js
@@ -15,6 +15,7 @@
var Floor = function(opt){
this.id = opt.id
this.side = opt.side
+ this.ceiling = opt.side & CEILING
this.mx = opt.mx
}
@@ -114,8 +115,6 @@
this.background.x = background.x || this.background.x
this.background.y = background.y || this.background.y
this.background.scale = background.scale || this.background.scale || 1
-
- var shouldFlip = this.side & (CEILING)
var mx, dx, dy
var w = Math.round( this.backgroundImage.naturalWidth * this.background.scale )
@@ -125,7 +124,7 @@
var region = mx.rect
- if (shouldFlip) {
+ if (this.ceiling) {
dx = Math.round( this.background.x - region.x.a )
dy = Math.round( this.background.y - region.y.a )
}