summaryrefslogtreecommitdiff
path: root/assets/javascripts/rectangles/models
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/rectangles/models')
-rw-r--r--assets/javascripts/rectangles/models/rect.js2
-rw-r--r--assets/javascripts/rectangles/models/room.js25
-rw-r--r--assets/javascripts/rectangles/models/wall.js13
3 files changed, 30 insertions, 10 deletions
diff --git a/assets/javascripts/rectangles/models/rect.js b/assets/javascripts/rectangles/models/rect.js
index 2d48e13..a5ae9bf 100644
--- a/assets/javascripts/rectangles/models/rect.js
+++ b/assets/javascripts/rectangles/models/rect.js
@@ -1,5 +1,3 @@
-var FRONT = 0x1, BACK = 0x2, LEFT = 0x4, RIGHT = 0x8,
- FRONT_BACK = FRONT | BACK, LEFT_RIGHT = LEFT | RIGHT
function sidesToString(sides){
var s = ""
diff --git a/assets/javascripts/rectangles/models/room.js b/assets/javascripts/rectangles/models/room.js
index c26efa9..34eed6a 100644
--- a/assets/javascripts/rectangles/models/room.js
+++ b/assets/javascripts/rectangles/models/room.js
@@ -1,3 +1,6 @@
+var FRONT = 0x1, BACK = 0x2, LEFT = 0x4, RIGHT = 0x8, FLOOR = 0x10, CEILING = 0x20
+ FRONT_BACK = FRONT | BACK, LEFT_RIGHT = LEFT | RIGHT, FLOOR_CEILING = FLOOR | CEILING
+
window.Room = (function(){
var Room = function(opt){
@@ -48,9 +51,27 @@ window.Room = (function(){
})
}
- Room.prototype.add_wall = function(){
- }
+ Room.prototype.group_walls = function(){
+ var base = this
+ var array_groups = {}, rect_groups = []
+
+ sort_wall_els_by_x_then_z(base.walls)
+
+ base.walls.forEach(function(wall){
+ var w = array_groups[ wall.side ]
+ if (w) {
+ w.forEach(function(ww){
+
+ })
+ }
+ else {
+ array_groups[ wall.side ] = [[wall]]
+ }
+ })
+ return groups
+ }
+
Room.prototype.clipTo = function(r){
// for each of this rect's regions split the region if necessary
var regions = this.regions
diff --git a/assets/javascripts/rectangles/models/wall.js b/assets/javascripts/rectangles/models/wall.js
index e25d2dd..b9705a2 100644
--- a/assets/javascripts/rectangles/models/wall.js
+++ b/assets/javascripts/rectangles/models/wall.js
@@ -1,20 +1,21 @@
-window.wall = (function(){
+window.Wall = (function(){
- var wall = function(opt){
+ var Wall = function(opt){
this.id = opt.id
this.room = opt.room
this.rect = opt.rect
this.mx = []
+ this.els = []
}
- wall.prototype.toString = function(){
+ Wall.prototype.toString = function(){
return this.rect.toString()
}
- wall.prototype.reset = function(){
+ Wall.prototype.reset = function(){
}
- wall.prototype.bind = function(){
+ Wall.prototype.bind = function(){
this.$walls.bind({
mouseover: function(){
},
@@ -26,6 +27,6 @@ window.wall = (function(){
})
}
- return wall
+ return Wall
})()