diff options
Diffstat (limited to 'assets/javascripts/rectangles/engine/scenery.js')
| -rw-r--r-- | assets/javascripts/rectangles/engine/scenery.js | 32 |
1 files changed, 21 insertions, 11 deletions
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 ) |
