Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>worst team at </title>
  6. <meta name="description" content="aaa">
  7. <meta name="author" content="">
  8. <meta name="viewport" content="width=device-width, initial-scale=1">
  9. <link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
  10. <link rel="stylesheet" href="css/normalize.css">
  11. <link rel="stylesheet" href="css/skeleton.css">
  12. <link rel="stylesheet" href="css/index.css">
  13. <link rel="icon" type="image/jpg" href="images/favicon.png">
  14. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script>
  15. <script>
  16. console.log("Welcome to piet.us!")
  17.  
  18.  
  19. function ranrange(range,x) {
  20. x = typeof x !== 'undefined' ? x : 0;
  21. return Math.floor(range*Math.random())+1+x;
  22. }
  23.  
  24. function battery() {
  25. this.x = 0
  26. this.y = 0
  27. this.image = document.getElementById("source")
  28. this.next = function next() {
  29. this.y += 1
  30. }
  31. }
  32.  
  33. function animate() {
  34. this.canvas = document.getElementById("canvas")
  35. this.canvas_delta_top = 10;
  36. this.canvas_delta_left = 10;
  37. this.x = 0;
  38. this.y = 0;
  39. this.ctx = this.canvas.getContext("2d");
  40. this.batteries = []
  41. this.b = new battery()
  42.  
  43. this.refresh = function refresh() {
  44. this.ctx.fillStyle="#ffd";
  45. this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height);
  46. }
  47.  
  48. this.resize = function resize() {
  49. this.canvas.width = window.innerWidth - 20;
  50. this.canvas.height = window.innerHeight - 20;
  51. }
  52.  
  53. this.create = function create() {
  54. y = -1
  55. b = new battery()
  56. b.y = -1 * (b.image.height + 10)
  57. b.x = (Math.random() * (this.canvas.width + 100)) - 50
  58. return b
  59. }
  60.  
  61. this.draw = function draw() {
  62. this.clear()
  63.  
  64. this.batteries.push(this.create()
  65.  
  66. for (var i=0; i<this.batteries.length; i++) {
  67. b = this.batteries[i]
  68. this.ctx.drawImage(b.image, b.x, b.y)
  69. b.next()
  70. }
  71.  
  72. this.batteries = this.batteries.filter(function(val, idx, arr) {
  73. return val.y < (this.canvas.height - 100);
  74. })
  75. }
  76.  
  77. this.clear = function clear() {
  78. this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
  79. }
  80. }
  81.  
  82. $(document).ready(function() {
  83. animate = new animate();
  84. window.addEventListener('resize', function(){animate.resize()}, false);
  85. animate.resize();
  86. function loop() {
  87. animate.draw();
  88. setTimeout(loop, 1);
  89. };
  90. loop();
  91. });
  92. </script>
  93. </head>
  94.  
  95. <img id="source" hidden="true" src="battery.png"></img>
  96. <canvas id="canvas"></canvas>
  97. <body>
  98. </body>
  99. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement