Advertisement
Guest User

moving_Blocks

a guest
Jun 13th, 2018
1,218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.81 KB | None | 0 0
  1. <!-- : class="re0">Begin batch script
  2. @echo off
  3. for /l %%a in (0,1,20) do start "" mshta.exe "%~f0"
  4. exit /b
  5. -->
  6. <!DOCTYPE html>
  7. <script>resizeTo(0,0);window.offscreenBuffering = "true";</script>
  8. <hta:application ID="oHTA" border="none" caption="no" contextmenu="no" innerborder="no" scroll="no" selection="no" >
  9. <html>
  10. <style>
  11.   html, body{width: 100%!!%;margin: 0px;}
  12.   #demo {background: red;width: 100%!!%;margin: 0;}
  13. </style>
  14.  
  15. <script>
  16. var timer,z,dX,dY,tOut;
  17. x=window.screenLeft; //get startposition
  18. y=window.screenLeft; //dito
  19. s=30; //size
  20. maxMove=20; //max  Pixels  to  move in one cycle
  21. cps=1000/30; //cycles  per 1000 milliseconds
  22. maxX=screen.availWidth-s;
  23. maxY=screen.availHeight-s;
  24.  
  25. function init(){
  26.   resizeTo(s,s);
  27.   moveTo(x,y);
  28.   randomTOut();
  29.   flee();
  30. };
  31.  
  32. //endless Loop! ...will break  by   clearTimeout(timer)
  33. function randomTOut(){
  34.   tOut=(Math.round((Math.random())*480)+20)*10;
  35.   moveControl();
  36.   timer=setTimeout(function(){randomTOut()},tOut);
  37. };
  38.  
  39. function moveControl(){
  40.   /* dX,dY become  random  between -maxMove and +maxMove,
  41.      the  sign determines the direction*/
  42.   dX=Math.round(Math.random()*maxMove*2-maxMove);
  43.   dY=Math.round(Math.random()*maxMove*2-maxMove);
  44. };
  45.  
  46. function flee(){
  47.   z=setInterval(function(){
  48.     if (x>0) {x+=dX;} else {dX=Math.abs(dX);x+=dX;};
  49.     if (y>0) {y+=dY;} else {dY=Math.abs(dY);y+=dY;};
  50.     if (x<maxX) {x+=dX;} else {dX=-Math.abs(dX);x+=dX;};
  51.     if (y<maxY) {y+=dY;} else {dY=-Math.abs(dY);y+=dY;};
  52.     moveTo(x,y);
  53.   }, cps);
  54. };
  55.  
  56. function closeW(){
  57.   //clear all timmerevents  befor  closing the window!  
  58.   clearTimeout(timer);
  59.   clearInterval(z);
  60.   close()
  61. };
  62. </script>
  63. <!-- collsion with the mouse  kills the window-->
  64. <body onload="init()" onmouseover="closeW()">
  65.   <div id="demo"></div>
  66. </body>
  67. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement