Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script src="js/jquery-1.9.1.min.js"></script>
- <style>
- .brick{
- position : fixed;
- height : 64;
- width : 64;
- }
- </style>
- <script>
- $(document).ready(function(){
- brick(0,10,"brick1.png",10);
- brick(14,10,"brick1.png",10);
- brick(5,10,"brick2.png",6);
- $(document).keydown(function(e){
- if (e.keyCode == 39) {
- $(".object").animate({'left':'-=100'},"slow","linear");
- }else if (e.keyCode == 37) {
- $(".object").animate({'left':'+=100'},"slow","linear");
- }
- });
- $(document).keyup(function(e){
- if (e.keyCode == 39 || e.keyCode == 37) {
- $(".object").stop(true);
- }
- });
- });
- function brick(start,size,brick,top){
- var top = top*64;
- var l = start*64;
- var x = 0;
- while(x < size){
- var z = $("#brick").html();
- var b = '<img src="img/' + brick;
- var b = b + '" class="brick brick object"';
- var b = b + ' style="left:' + l;
- var b = b + 'px;top:' + top + 'px">';
- $("#brick").html(z + b);
- l+=64;
- x+=1;
- }
- }
- </script>
- </head>
- <body>
- <div id="brick"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement