summaryrefslogtreecommitdiff
path: root/assets/javascripts/rectangles/engine
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-04-29 16:42:13 -0400
committerJules Laplace <jules@okfoc.us>2014-04-29 16:42:13 -0400
commit277afee0a66822113de9db44c8a60256b5c8491a (patch)
treef5d85c8ce895343b63a0560ac76ce1c200153751 /assets/javascripts/rectangles/engine
parentc89f1107041a4ac8a513e4e2e7c1c3da984b1c59 (diff)
need to rethink this gravity stuff later
Diffstat (limited to 'assets/javascripts/rectangles/engine')
-rw-r--r--assets/javascripts/rectangles/engine/scenery.js46
1 files changed, 29 insertions, 17 deletions
diff --git a/assets/javascripts/rectangles/engine/scenery.js b/assets/javascripts/rectangles/engine/scenery.js
index 4ac03b8..e25805b 100644
--- a/assets/javascripts/rectangles/engine/scenery.js
+++ b/assets/javascripts/rectangles/engine/scenery.js
@@ -8,15 +8,15 @@ var scenery = new function(){
var base = this;
- base.mouse = new mouse ()
+ base.mouse = new mouse ({ use_offset: false })
base.init = function(){
var urls = [
- "http://www.donedwardsart.com/upload/2008-4-18_resting%20wood%20duck.jpg",
- "http://cdn.dailypainters.com/paintings/_four_quackers__baby_duck_oil_painting_by_texas_ar_3d3162fd43295d059068ae1c204367e3.jpg",
- "http://2.bp.blogspot.com/-apEunnES6wU/UGdc6skZqzI/AAAAAAAAB3k/D6yO6llpFcg/s1600/Sunny+Side+Duck.JPG",
- "http://imagecache.artistrising.com/artwork/lrg//5/559/5UD2000A.jpg",
- "http://media-cache-ec0.pinimg.com/736x/fc/a7/31/fca731130ffb964a434fb90edecd22c3.jpg",
+ "http://okfocus.s3.amazonaws.com/office/ducks/duck1.jpg",
+ "http://okfocus.s3.amazonaws.com/office/ducks/duck2.jpg",
+ "http://okfocus.s3.amazonaws.com/office/ducks/duck3.jpg",
+ "http://okfocus.s3.amazonaws.com/office/ducks/duck4.jpg",
+ "http://okfocus.s3.amazonaws.com/office/ducks/duck5.jpg",
]
var loader = new Loader(function(){
base.load(loader.images)
@@ -52,7 +52,7 @@ var scenery = new function(){
backface: false,
})
- var center = wall.center_for(img)
+ var center = wall.center_for(img, null)
mx_img.move({
x: center.a,
z: center.b,
@@ -75,47 +75,59 @@ var scenery = new function(){
x = mx_img.x
y = mx_img.y
z = mx_img.z
- mx_img.el.style.pointerEvents = "none"
bounds = wall.bounds_for(img)
+ document.body.classList.add("dragging")
})
base.mouse.tube.on("enter", function(e, new_wall, cursor){
if (! dragging) return
if (new_wall.uid == wall.uid) return
if (! new_wall.fits(img)) return
bounds = new_wall.bounds_for(img)
- center = new_wall.center_for(img, cursor.x.magnitude())
+ center = new_wall.center_for(img)
+// 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
+// }
+ x = center.a
+ z = center.b
+
+ cursor.a = cursor.b
+
mx_img.move({
x: center.a,
z: center.b,
rotationY: wall_rotation[ new_wall.side ]
})
-
- cursor.x.invert()
-
+
wall = new_wall
})
base.mouse.tube.on("drag", function(e, cursor){
if (! dragging) return
+
mx_img.y = bounds.y.clamp( y - cursor.y.magnitude()*cursor_amp )
switch (wall.side) {
case FRONT:
- mx_img.x = bounds.x.clamp( x + cursor.x.magnitude()*cursor_amp )
+ mx_img.x = bounds.x.clamp( x - cursor.x.magnitude()*cursor_amp )
break
case BACK:
- mx_img.x = bounds.x.clamp( x - cursor.x.magnitude()*cursor_amp )
+ mx_img.x = bounds.x.clamp( x + cursor.x.magnitude()*cursor_amp )
break
case LEFT:
- mx_img.z = bounds.x.clamp( z - cursor.x.magnitude()*cursor_amp )
+ mx_img.z = bounds.x.clamp( z + cursor.x.magnitude()*cursor_amp )
break
case RIGHT:
- mx_img.z = bounds.x.clamp( z + cursor.x.magnitude()*cursor_amp )
+ mx_img.z = bounds.x.clamp( z - cursor.x.magnitude()*cursor_amp )
break
}
})
base.mouse.tube.on("up", function(e, cursor){
dragging = false
- mx_img.el.style.pointerEvents = "auto"
+ document.body.classList.remove("dragging")
})
}