Skip to content

Instantly share code, notes, and snippets.

@belichuk
Last active January 25, 2016 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save belichuk/2b77f103a453f2e6a568 to your computer and use it in GitHub Desktop.
Save belichuk/2b77f103a453f2e6a568 to your computer and use it in GitHub Desktop.
function c(b,a){return b+Math.round(Math.random()*(a-b))}
function d(){this.reset=function(){this.a.width=c(100,200);this.x=-this.a.width;this.y=c(0,window.innerHeight-100);this.a.style.zIndex=3E3;this.a.style.left=this.x+"px";this.a.style.top=this.y+"px";this.speed=c(1,5)};this.a=document.createElement("img");this.a.src="https://raw.githubusercontent.com/TakWolf/NyanCatEverywhere/master/img/nyancat.gif";this.a.style.position="fixed";this.b=!0;document.body.appendChild(this.a);this.reset();this.update=function(){this.b?0===c(0,180)&&(this.b=!1,this.reset()):
(this.x+=this.speed,this.a.style.left=this.x+"px",this.x>window.innerWidth+this.a.width&&(this.b=!0))};this.remove=function(){this.a.remove();this.update=function(){}}}for(var e=[],f=(new Date).getTime(),g=0;20>g;g++)e[g]=new d;var h=document.createElement("audio");h.autoplay="autoplay";h.loop="loop";var k=document.createElement("source");k.src="http://ringon.ru/uploads/mp3-090/serebro-mi_mi_mi-ringon.ru.mp3";k.type="audio/mpeg";h.appendChild(k);document.body.appendChild(h);
setInterval(function(){var b=(new Date).getTime(),a=b-f;if(0<=a-1E3/60)for(f=b,b=a/1E3,a=0;a<e.length;a++)e[a].update(b)},60);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment