diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-06-03 16:24:10 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-06-03 16:24:28 -0400 |
| commit | 607f69c67a5b4dc72d2754192e3cdf67d0ad11d0 (patch) | |
| tree | 6556e7922c5bedb274bb1650e5dd100643a7895d /assets/javascripts/rectangles/models/wall.js | |
| parent | d31259291d807c851de4396921e0c26b6dd8dce2 (diff) | |
partitioning client and serveR
Diffstat (limited to 'assets/javascripts/rectangles/models/wall.js')
| -rw-r--r-- | assets/javascripts/rectangles/models/wall.js | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/assets/javascripts/rectangles/models/wall.js b/assets/javascripts/rectangles/models/wall.js deleted file mode 100644 index 4270551..0000000 --- a/assets/javascripts/rectangles/models/wall.js +++ /dev/null @@ -1,120 +0,0 @@ -window.Wall = (function(){ - - var Wall = function(opt){ - this.id = opt.id - this.uid = Uid() - this.room = opt.room - this.rect = opt.rect || new Rect (0,0,0,0) - this.rect.sides = opt.side - this.side = opt.side - this.mx = [] - this.els = [] - if (opt.el) { - this.mx.push(opt.el) - } - } - - Wall.prototype.toString = function(){ - return this.rect.toString() - } - - Wall.prototype.reset = function(){ - } - - Wall.prototype.destroy = function(){ - this.mx.forEach(function(mx){ - mx.destroy && mx.destroy() - }) - this.room = this.rect = this.mx = this.els = null - } - - Wall.prototype.bind = function(){ - var base = this - base.$walls = $( this.mx.map(function(mx){ return mx.el }) ) - base.$walls.bind({ - mouseover: function(){ - }, - mouseenter: function(e){ - Scenery.mouse.mouseenter(e, base) - }, - mousemove: function(e){ - }, - mousedown: function(){ - base.randomize_colors() - console.log(sidesToString(base.side)) - } - }) - } - - Wall.prototype.bounds_for = function(img) { - var coord = this.side & FRONT_BACK ? this.rect.x : this.rect.y - return new Rect( new vec2( coord.a + img.width/2, coord.b - img.width/2 ), - new vec2( img.height/2, Rooms.list[this.room].height - img.height/2 ) ) - } - Wall.prototype.fits = function(img){ - if (this.side & FRONT_BACK && this.rect.x.length() < img.width) { - return false - } - if (this.side & LEFT_RIGHT && this.rect.y.length() < img.width) { - return false - } - return true - } - - Wall.prototype.center = function(offset){ - - offset = offset || 0 - - var major_axis, minor_axis - if (this.side & FRONT_BACK) { - major_axis = this.rect.x - minor_axis = this.rect.y - } - else { - major_axis = this.rect.y - minor_axis = this.rect.x - } - - switch (this.side) { - case FRONT: - x = major_axis.midpoint() - z = minor_axis.a + painting_distance_from_wall + offset - break - case BACK: - x = major_axis.midpoint() - z = minor_axis.b - painting_distance_from_wall + offset - break - case LEFT: - x = minor_axis.a + painting_distance_from_wall + offset - z = major_axis.midpoint() - break - case RIGHT: - x = minor_axis.b - painting_distance_from_wall + offset - z = major_axis.midpoint() - break - } - - return new vec2 (x, z) - } - - Wall.prototype.color = function(color){ - this.$walls && this.$walls.css("background-color", color) - } - - Wall.prototype.siblings = function(){ - var base = this - var match = base.side | base.half_side - var walls = Rooms.list[this.room].walls.filter(function(w){ - return (w.side | w.half_side) & match - }) - return walls; - } - - Wall.prototype.randomize_colors = function(){ - var color = choice(window.colors) - this.siblings().forEach(function(w){ w.color(color) }) - } - - return Wall - -})() |
