summaryrefslogtreecommitdiff
path: root/assets/javascripts/rectangles/models/wall.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/rectangles/models/wall.js')
-rw-r--r--assets/javascripts/rectangles/models/wall.js32
1 files changed, 8 insertions, 24 deletions
diff --git a/assets/javascripts/rectangles/models/wall.js b/assets/javascripts/rectangles/models/wall.js
index 97083c7..8a3784b 100644
--- a/assets/javascripts/rectangles/models/wall.js
+++ b/assets/javascripts/rectangles/models/wall.js
@@ -59,50 +59,34 @@ window.Wall = (function(){
return true
}
- Wall.prototype.center_for = function(img, gravity){
- var left
- gravity = gravity || 0
-
+ Wall.prototype.center_for = function(img){
+
var major_axis, minor_axis
if (this.side & FRONT_BACK) {
major_axis = this.rect.x
minor_axis = this.rect.y
}
else {
- minor_axis = this.rect.x
major_axis = this.rect.y
+ minor_axis = this.rect.x
}
-
- // left side addition
- if (gravity > 0) {
- console.log("gravity left")
- left = major_axis.b - img.width/2
- }
- // right side addition
- else if (gravity < 0) {
- console.log("gravity right")
- left = major_axis.a + img.width/2
- }
- else {
- left = major_axis.midpoint()
- }
-
+
switch (this.side) {
case FRONT:
- x = left
+ x = major_axis.midpoint()
z = minor_axis.a + 10
break
case BACK:
- x = left
+ x = major_axis.midpoint()
z = minor_axis.b - 10
break
case LEFT:
x = minor_axis.a + 10
- z = left
+ z = major_axis.midpoint()
break
case RIGHT:
x = minor_axis.b - 10
- z = left
+ z = major_axis.midpoint()
break
}