summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/models
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/rectangles/models')
-rw-r--r--public/assets/javascripts/rectangles/models/rect.js4
-rw-r--r--public/assets/javascripts/rectangles/models/room.js8
-rw-r--r--public/assets/javascripts/rectangles/models/vec2.js4
-rw-r--r--public/assets/javascripts/rectangles/models/wall.js30
4 files changed, 34 insertions, 12 deletions
diff --git a/public/assets/javascripts/rectangles/models/rect.js b/public/assets/javascripts/rectangles/models/rect.js
index ec32ab7..5952f6a 100644
--- a/public/assets/javascripts/rectangles/models/rect.js
+++ b/public/assets/javascripts/rectangles/models/rect.js
@@ -39,6 +39,10 @@
Rect.prototype.clone = function(){
return new Rect( this.x.clone(), this.y.clone() )
}
+ Rect.prototype.assign = function(r) {
+ this.x.assign(r.x)
+ this.y.assign(r.y)
+ }
Rect.prototype.center = function(){
return new vec2(this.x.midpoint(), this.y.midpoint())
}
diff --git a/public/assets/javascripts/rectangles/models/room.js b/public/assets/javascripts/rectangles/models/room.js
index 937c928..33a94d0 100644
--- a/public/assets/javascripts/rectangles/models/room.js
+++ b/public/assets/javascripts/rectangles/models/room.js
@@ -40,6 +40,14 @@
this.focused = false
}
+ Room.prototype.copy = function(){
+ return {
+ id: this.id,
+ rect: this.rect.clone(),
+ height: this.height,
+ }
+ }
+
Room.prototype.toString = function(){
return this.rect.toString()
}
diff --git a/public/assets/javascripts/rectangles/models/vec2.js b/public/assets/javascripts/rectangles/models/vec2.js
index 104c6f7..214feb9 100644
--- a/public/assets/javascripts/rectangles/models/vec2.js
+++ b/public/assets/javascripts/rectangles/models/vec2.js
@@ -17,6 +17,10 @@
vec2.prototype.clone = function(){
return new vec2(this.a, this.b)
}
+ vec2.prototype.assign = function(v){
+ this.a = v.a
+ this.b = v.b
+ }
vec2.prototype.abs = function(){
if (this.b < this.a) {
this.invert()
diff --git a/public/assets/javascripts/rectangles/models/wall.js b/public/assets/javascripts/rectangles/models/wall.js
index fdc91fd..460963b 100644
--- a/public/assets/javascripts/rectangles/models/wall.js
+++ b/public/assets/javascripts/rectangles/models/wall.js
@@ -52,7 +52,16 @@
// base.randomize_colors()
// console.log(sidesToString(base.side))
if (Scenery.nextMedia) {
- Scenery.addNextToWall(base, mx)
+ var scenery = Scenery.addNextToWall(base)
+
+ UndoStack.push({
+ type: 'create-scenery',
+ undo: { id: scenery.id },
+ redo: scenery.serialize(),
+ })
+
+ // TODO: watch individual scenery object here
+ Minotaur.watch( app.router.editorView.settings )
}
else if (Scenery.nextWallpaper) {
base.wallpaper()
@@ -135,18 +144,15 @@
Wall.prototype.wallpaper = function(){
var useX = this.side & FRONT_BACK
var shouldFlip = this.side & (LEFT | BACK)
- this.siblings().forEach(function(w){
- w.mx.forEach(function(mx){
-
- var partitionOffset = useX ? mx.x : mx.z
- if (shouldFlip) partitionOffset *= -1
- partitionOffset += mx.width/2
- var floorOffset = mx.y + mx.height/2
+ this.mx.forEach(function(mx){
+ var partitionOffset = useX ? mx.x : mx.z
+ if (shouldFlip) partitionOffset *= -1
+ partitionOffset += mx.width/2
+ var floorOffset = mx.y + mx.height/2
- mx.el.style.backgroundImage = Scenery.nextWallpaper
- mx.el.style.backgroundPosition = (~~partitionOffset) + "px " + (~~floorOffset) + "px"
- })
- })
+ mx.el.style.backgroundImage = Scenery.nextWallpaper
+ mx.el.style.backgroundPosition = (~~partitionOffset) + "px " + (~~floorOffset) + "px"
+ })
}
Wall.prototype.outline = function(){