var dirty = []; $("#demo").load('http://collusioni.st/axonome/demos/isometric1.html'); var word = new Letters("axono.me",1,2,0); var shadow = new Letters("axono.me",1,2,2); $('#shadow').iso({ unwalkables: shadow, tile_offset: [64,0], tile_width:16, tile_height:8, iso_tile_height:9, max_x: 43, max_y: 9, layers:3} ); $('#board').iso({ unwalkables: word, tile_offset: [64,0], tile_width:16, tile_height:8, iso_tile_height:9, max_x: 43, render_all: false, max_y: 9} ); var original_top = $('#board').css('top'); var original_left = $('#board').css('left'); var quit_it = 0; var tile_queue = new Array(); $('#board .dirt').each(function() { tile_queue.push(this); }); var color_classes = ["red","blue"]; function serial_bounce() { var move_by = parseInt(Math.random() * 10)+5; if (tile_queue.length > 0) { var tile = $(tile_queue.shift()); tile.addClass(color_class).animate({top: '-=' + move_by}, 50).animate({top: '+=' + move_by}, 50, function() { serial_bounce(); }); } else { return; } }; function r() { //return parseInt(Math.random() * 100); return 32; } function explode() { $.each(tile_queue, function() { var id_parts = this.id.split("_"); var tile = $(this); var orig_top = this.offsetTop; var orig_left = this.offsetLeft; tile.data("orig_pos",[orig_top, orig_left]); var color_class = color_classes[Math.floor(Math.random()*2)]; var shadow = $('#shadow_tile_' + id_parts[2] + '_' + id_parts[3] + '_' + 2); shadow.data("orig_pos", [shadow[0].offsetTop, shadow[0].offsetLeft]); var trajectories = ["north", "south", "west"]; switch(trajectories[parseInt(Math.random() * 4)]) { case "north": tile.animate({top: '-=' + 16}); //.animate({top: '+=' + 16}); break; case "west": tile.animate({top: '-=' + 32, left: '-=' + 32}); //.animate({top: '+=' + 32, left: '+=' + 32}); shadow.animate({left: '-=' + 48}); //.animate({left: '+=' + 48}); break; case "east": tile.animate({top: '-=' + 32, left: '+=' + 32}); //.animate({top: '+=' + 32, left: '-=' + 32}); shadow.animate({left: '+=' + 32}); //.animate({left: '-=' + 16}); break; case "south": tile.animate({top: '-=' + 0, left: '-=' + 16}); //.animate({top: '+=' + 0, left: '+=' + 16}); shadow.animate({left: '-=' + 16}); //.animate({left: '-=' + 4}); break; } }); }; function implode() { $.each(tile_queue, function() { var id_parts = this.id.split("_"); var tile = $(this); var shadow = $('#shadow_tile_' + id_parts[2] + '_' + id_parts[3] + '_' + 2); var orig_top = tile.data("orig_pos")[0]; var orig_left = tile.data("orig_pos")[1]; tile.animate({top: orig_top, left: orig_left}); shadow_orig_top = shadow.data("orig_pos")[0]; shadow_orig_left = shadow.data("orig_pos")[1]; shadow.animate({top: shadow_orig_top, left: shadow_orig_left}); }); } $('#exploding').mouseenter(function() { explode(); }); $('#exploding').mouseleave(function() { implode(); });
<div id="exploding"> <div id="shadow"></div> <div id="board"></div> </div>