summaryrefslogtreecommitdiff
path: root/assets/javascripts/rectangles/models/room.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/rectangles/models/room.js')
-rw-r--r--assets/javascripts/rectangles/models/room.js56
1 files changed, 32 insertions, 24 deletions
diff --git a/assets/javascripts/rectangles/models/room.js b/assets/javascripts/rectangles/models/room.js
index b66d868..c26efa9 100644
--- a/assets/javascripts/rectangles/models/room.js
+++ b/assets/javascripts/rectangles/models/room.js
@@ -1,23 +1,22 @@
-window.room = (function(){
+window.Room = (function(){
- var room = function(opt){
+ var Room = function(opt){
this.id = opt.id || clipper.rooms.length
this.rect = opt.rect
this.regions = []
+ this.walls = []
+ this.floor = []
+ this.ceiling = []
this.height = opt.height || 200
this.focused = false
-
- this.$walls = $([])
- this.$floor = $([])
- this.$ceiling = $([])
}
- room.prototype.toString = function(){
+ Room.prototype.toString = function(){
return this.rect.toString()
}
- room.prototype.reset = function(){
+ Room.prototype.reset = function(){
var copy = this.rect.clone()
copy.id = this.id
copy.sides = FRONT | BACK | LEFT | RIGHT
@@ -26,24 +25,33 @@ window.room = (function(){
this.intersects = []
this.constructed = false
- this.$walls = $([])
- this.$floor = $([])
- this.$ceiling = $([])
+ this.walls = []
+ this.floor = []
+ this.ceiling = []
}
- room.prototype.bind = function(){
- this.$walls.bind({
- mouseover: function(){
- },
- mousemove: function(e){
- },
- mousedown: function(){
- $(this).css("background-color", choice(window.palettes.colors))
- }
+ Room.prototype.bind = function(){
+ var base = this
+ base.walls.forEach(function(wall){
+ $(wall.el).bind({
+ mouseover: function(){
+ },
+ mousemove: function(e){
+ var color = choice(window.palettes.colors)
+ base.walls.forEach(function(wall){
+ $(wall.el).css("background-color", color)
+ })
+ },
+ mousedown: function(){
+ }
+ })
})
}
+
+ Room.prototype.add_wall = function(){
+ }
- room.prototype.clipTo = function(r){
+ Room.prototype.clipTo = function(r){
// for each of this rect's regions split the region if necessary
var regions = this.regions
var splits
@@ -57,7 +65,7 @@ window.room = (function(){
this.regions = regions
}
- room.prototype.collides = function(x,y){
+ Room.prototype.collides = function(x,y){
var collision = 0, wall_collision, contains_x, contains_y
this.regions.forEach(function(r){
if (! r.sides) return
@@ -94,7 +102,7 @@ window.room = (function(){
return collision
}
- room.prototype.collidesDisc = function(x,y,radius){
+ Room.prototype.collidesDisc = function(x,y,radius){
var collision = 0, wall_collision, contains_x, contains_y
this.regions.forEach(function(r){
if (! r.sides) return
@@ -131,7 +139,7 @@ window.room = (function(){
return collision
}
- return room
+ return Room
})()