summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulie Lala <jules@okfoc.us>2014-04-29 00:38:46 -0400
committerJulie Lala <jules@okfoc.us>2014-04-29 01:00:46 -0400
commit637ed631616a62940aeda1bc28d125c6ba84cbef (patch)
tree20aaff2c07c057c8860ec0e349b9d1234f33386f
parente0dfff4729b342e8f573238135cb811bb5a0f43b (diff)
baby ducks
-rw-r--r--assets/javascripts/mx/extensions/mx.movements.js8
-rw-r--r--assets/javascripts/rectangles/engine/builder.js2
-rw-r--r--assets/javascripts/rectangles/engine/clipper.js2
-rw-r--r--assets/javascripts/rectangles/engine/scenery.js32
-rw-r--r--assets/javascripts/rectangles/models/room.js1
-rw-r--r--assets/javascripts/rectangles/models/wall.js6
-rw-r--r--assets/javascripts/rectangles/util/colors.js6
-rw-r--r--assets/javascripts/rectangles/util/mouse.js5
-rw-r--r--rectangles.html3
9 files changed, 40 insertions, 25 deletions
diff --git a/assets/javascripts/mx/extensions/mx.movements.js b/assets/javascripts/mx/extensions/mx.movements.js
index d6d5e04..d9d132d 100644
--- a/assets/javascripts/mx/extensions/mx.movements.js
+++ b/assets/javascripts/mx/extensions/mx.movements.js
@@ -229,16 +229,16 @@ MX.Movements = function (cam, viewHeight) {
}
if (turnUp) {
- cam.rotationX = clamp( cam.rotationX - vrrrr, rotationX_min, rotationX_max)
+ cam.rotationX = clamp( cam.rotationX - vrrrr*s, rotationX_min, rotationX_max)
}
if (turnDown) {
- cam.rotationX = clamp( cam.rotationX + vrrrr, rotationX_min, rotationX_max)
+ cam.rotationX = clamp( cam.rotationX + vrrrr*s, rotationX_min, rotationX_max)
}
if (turnLeft) {
- cam.rotationY += vrrrr
+ cam.rotationY += vrrrr*s
}
if (turnRight) {
- cam.rotationY -= vrrrr
+ cam.rotationY -= vrrrr*s
}
pos.x += vx
diff --git a/assets/javascripts/rectangles/engine/builder.js b/assets/javascripts/rectangles/engine/builder.js
index 0d2240d..bdc52ed 100644
--- a/assets/javascripts/rectangles/engine/builder.js
+++ b/assets/javascripts/rectangles/engine/builder.js
@@ -281,7 +281,7 @@ var builder = new function(){
el.side = 0
el.rect = null
el.destroy = function(){
- this.el = this.rect = this.rect.x = this.rect.y = null
+ this.el = this.rect = null
}
// possible if walls are opaque
diff --git a/assets/javascripts/rectangles/engine/clipper.js b/assets/javascripts/rectangles/engine/clipper.js
index 7c2f048..68fad15 100644
--- a/assets/javascripts/rectangles/engine/clipper.js
+++ b/assets/javascripts/rectangles/engine/clipper.js
@@ -25,7 +25,7 @@ var clipper = new function(){
rooms.push( new Room({
id: base.rooms.length,
rect: rect,
- height: quantize(randrange(200,500), 50),
+ height: quantize(randrange(300,800), 50),
}) )
}
diff --git a/assets/javascripts/rectangles/engine/scenery.js b/assets/javascripts/rectangles/engine/scenery.js
index 79ffbf2..c9be6ef 100644
--- a/assets/javascripts/rectangles/engine/scenery.js
+++ b/assets/javascripts/rectangles/engine/scenery.js
@@ -9,19 +9,29 @@ var scenery = new function(){
var base = this;
base.init = function(){
- var url = "https://s3.amazonaws.com/luckyplop/f5b2c20e602cdfc86383910f294dcf23d91fa956.png"
- var img = new Image ()
- img.onload = function(){ base.load(img) }
- img.src = url
- if (img.complete) base.load(img)
+ 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",
+
+ ]
+ var loader = new Loader(function(){
+ base.load(loader.images)
+ })
+ loader.preloadImages(urls)
}
- base.load = function(img){
- img.width = 300
- img.height = ~~(300 * img.naturalHeight/img.naturalWidth)
+ base.load = function(images){
+ images.forEach(function(img){
+ img.width = 300
+ img.height = ~~(300 * img.naturalHeight/img.naturalWidth)
+ })
+
clipper.rooms.forEach(function(room){
room.walls.forEach(function(wall){
- new_image(wall, img)
+ new_image(wall, choice(images))
})
})
}
@@ -57,7 +67,7 @@ var scenery = new function(){
var mx_img = new MX.Image({
src: img.src,
x: x,
- y: img.height/3,
+ y: clipper.rooms[wall.room].height/2 - img.height/2 - 20,
z: z,
scale: 300/img.naturalWidth,
rotationY: wall_rotation[ wall.side ],
@@ -77,7 +87,7 @@ var scenery = new function(){
x = mx_img.x
y = mx_img.y
z = mx_img.z
- bounds = bounds_for(wall, img)
+ bounds = wall.bounds_for(img)
})
my_mouse.tube.on("drag", function(e, cursor){
mx_img.y = bounds.y.clamp( y - cursor.y.magnitude()*cursor_amp )
diff --git a/assets/javascripts/rectangles/models/room.js b/assets/javascripts/rectangles/models/room.js
index a321b7f..440dacb 100644
--- a/assets/javascripts/rectangles/models/room.js
+++ b/assets/javascripts/rectangles/models/room.js
@@ -62,7 +62,6 @@ window.Room = (function(){
// ignore half-walls for now
if (! wall.side) return;
-
if (side_groups[ wall.side ]) {
side_groups[ wall.side ].push(wall)
}
diff --git a/assets/javascripts/rectangles/models/wall.js b/assets/javascripts/rectangles/models/wall.js
index b1af41e..ecc334d 100644
--- a/assets/javascripts/rectangles/models/wall.js
+++ b/assets/javascripts/rectangles/models/wall.js
@@ -40,10 +40,10 @@ window.Wall = (function(){
})
}
- Wall.prototype.bounds_for(img) {
- var coord = wall.side & FRONT_BACK ? wall.rect.x : wall.rect.y
+ 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, clipper.rooms[wall.room].height - img.height/2 ) )
+ new vec2( img.height/2, clipper.rooms[this.room].height - img.height/2 ) )
}
var bzz = 0
diff --git a/assets/javascripts/rectangles/util/colors.js b/assets/javascripts/rectangles/util/colors.js
index 17f0d8f..bb3662e 100644
--- a/assets/javascripts/rectangles/util/colors.js
+++ b/assets/javascripts/rectangles/util/colors.js
@@ -15,6 +15,12 @@
"rgba(0,0,0,0.3)",
"rgba(0,0,0,0.4)",
],
+ bone: [
+ "hsla(0,0%,90%,0.95)",
+ "hsla(0,0%,80%,0.95)",
+ "hsla(0,0%,85%,0.95)",
+ "hsla(0,0%,75%,0.95)",
+ ],
colors: [
"rgba(255,0,0,0.5)",
"rgba(255,128,0,0.5)",
diff --git a/assets/javascripts/rectangles/util/mouse.js b/assets/javascripts/rectangles/util/mouse.js
index 09fee0d..87a68fc 100644
--- a/assets/javascripts/rectangles/util/mouse.js
+++ b/assets/javascripts/rectangles/util/mouse.js
@@ -106,12 +106,11 @@ function mouse (opt) {
base.tube("move", e, base.cursor)
}
}
- base.mouseup = function(e){
- e.stopPropagation()
-
+ base.mouseup = function(e){
var pos, new_cursor
if (base.down) {
+ e.stopPropagation()
base.down = false
pos = positionFromMouse(e)
new_cursor = new Rect (pos.a, pos.b)
diff --git a/rectangles.html b/rectangles.html
index de8cf74..335613c 100644
--- a/rectangles.html
+++ b/rectangles.html
@@ -54,7 +54,8 @@ body > div {
<select id="palette">
<option>colors</option>
<option>redblue</option>
- <option selected>gray</option>
+ <option>gray</option>
+ <option selected>bone</option>
<option>alpha</option>
<option>white</option>
<option>black</option>