Guest User

https://www.reddit.com/user/jcunews1/

a guest
Sep 22nd, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. (function() {
  2. var im = new Image(),
  3. au, doneTurn,
  4. turnX, wid, hei, xDelta, yDelta,
  5. minXspd = 4, maxXspd = 8,
  6. maxYspd = 4, maxInus = 10,
  7. x, y;
  8.  
  9. function newDeltas() {
  10. xDelta = Math.trunc(Math.random() * (maxXspd - minXspd)) + minXspd;
  11. yDelta = Math.trunc(Math.random() * ((maxYspd * 2) + 1)) - maxYspd;
  12. }
  13. function newMods() {
  14. doneTurn = false;
  15. turnX = Math.trunc(Math.random() * innerWidth)-wid;
  16. newDeltas();
  17. x = innerWidth;
  18. y = Math.trunc(Math.random() * (innerHeight + hei)) - hei;
  19. }
  20.  
  21. window.inus = window.inus || 0;
  22. if(window.inus >= maxInus) return;
  23. if(!window.inus) {
  24. au = new Audio("https://omfgdogs.com/omfgdogs.mp3");
  25. }
  26. window.inus++;
  27. im.src = "http://i.imgur.com/ZgDxHDF.gif";
  28. im.style.cssText = "position:absolute;visibility:hidden;left:" + x + "px;top:" + y + "px";
  29. im.onload = function() {
  30. wid = im.width;
  31. hei = im.height;
  32. newMods();
  33. im.style.visibility = "";
  34. if(au) {
  35. au.loop = true;
  36. au.play();
  37. }
  38. setInterval(function() {
  39. x -= xDelta;
  40. y -= yDelta;
  41. if ((x < -wid) || (y < -hei) || (y > innerHeight)) {
  42. newMods();
  43. } else if (!doneTurn && (x <= turnX)) {
  44. doneTurn = true;
  45. newDeltas();
  46. }
  47. im.style.left = x + "px";
  48. im.style.top = y + "px";
  49. }, 25);
  50. };
  51. document.body.appendChild(im);
  52. })()
Add Comment
Please, Sign In to add comment