From 9f4204d35f1dbd861417cd8a04bb26c46299f55a Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 5 May 2014 15:56:07 -0400 Subject: happy with refactor --- .../rectangles/engine/scenery/_scenery.js | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 assets/javascripts/rectangles/engine/scenery/_scenery.js (limited to 'assets/javascripts/rectangles/engine/scenery/_scenery.js') diff --git a/assets/javascripts/rectangles/engine/scenery/_scenery.js b/assets/javascripts/rectangles/engine/scenery/_scenery.js new file mode 100644 index 0000000..dbd9dbe --- /dev/null +++ b/assets/javascripts/rectangles/engine/scenery/_scenery.js @@ -0,0 +1,44 @@ + +var Scenery = new function(){ + + var base = this; + + base.images = [] + + base.mouse = new mouse ({ use_offset: false }) + + base.init = function(){ + var urls = [ + "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) + }) + loader.preloadImages(urls) + } + + base.load = function(images){ + images.forEach(function(img){ + img.width = 300 + img.height = ~~(300 * img.naturalHeight/img.naturalWidth) + }) + + Rooms.forEach(function(room){ + room.walls.forEach(function(wall){ + var img = choice(images) + if (wall.fits(img)) { + var scene_img = new Scenery.image (wall, img) + base.images.push(scene_img) + scene_img.init() + } + }) + }) + } + + return base +} + -- cgit v1.2.3-70-g09d2