diff options
Diffstat (limited to 'assets/javascripts/rectangles/engine')
| -rw-r--r-- | assets/javascripts/rectangles/engine/builder.js | 2 | ||||
| -rw-r--r-- | assets/javascripts/rectangles/engine/clipper.js | 2 | ||||
| -rw-r--r-- | assets/javascripts/rectangles/engine/scenery.js | 32 |
3 files changed, 23 insertions, 13 deletions
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 ) |
