diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-04-25 16:08:48 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-04-25 16:08:48 -0400 |
| commit | 1b06bfa4b67747229c3283a9466047b1daece035 (patch) | |
| tree | cd889dd15463324be0c03aaa96bca6eeaf89052e /assets/javascripts/rectangles/models/room.js | |
| parent | 0772bb5e55d0d00c925620a27b59a7f52aaa4199 (diff) | |
improve names
Diffstat (limited to 'assets/javascripts/rectangles/models/room.js')
| -rw-r--r-- | assets/javascripts/rectangles/models/room.js | 56 |
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 })() |
