Guest User

Untitled

a guest
Dec 12th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5.  
  6.  
  7. function openwindow(){
  8.  
  9. window.open('Game.html','', 'resizable=no , scrollbars=no , toolbar=no , width=500 , height=600');
  10. Gamespace();
  11. }
  12.  
  13.  
  14.  
  15.  
  16. function Gamespace(){
  17. var ball= document.getElementById("ball");
  18. var intialspeedX= Math.floor(Math.random()*11);
  19. var intialspeedY= Math.floor(Math.random()*11);
  20. var ballspeedX = intialspeedX;
  21. var ballspeedY = intialspeedY;
  22. var ballX = 200;
  23. var ballY = 300;
  24. var time = Date.now();
  25. var previousframe = Date.now();
  26. var deltaT = 0;
  27.  
  28.  
  29.  
  30.  
  31. var updater = function(){
  32.  
  33. previousframe= time;
  34. time= Date.now();
  35. deltaT = (time- previousframe)/1000;
  36.  
  37.  
  38. //move the ball
  39. ballX += ballspeedX * deltaT;
  40. ballY += ballspeedY * deltaT;
  41.  
  42. /*top wall
  43. if (ballY <=10){
  44. ballspeedY = -ballspeedY;
  45. }
  46. //left
  47. if (ballY <=10){
  48. ballspeedX = -ballspeedX;
  49. }
  50. //right
  51. if (ballX >= 480){
  52. ballspeedX = -ballspeedX;
  53. }
  54. //bottom
  55. if(ballY >= 580){
  56. ballspeedY = -ballspeedY;
  57. }*/
  58.  
  59. ball.style.left = ballX + "px";
  60. ball.style.top = ballY + "px";
  61. }
  62.  
  63. setInterval(updater,1000/60);
  64.  
  65. }
  66.  
  67.  
  68.  
  69.  
  70.  
  71. //don't mind this stuff
  72.  
  73. /*doc.write(<img alt="five" height="100" src="../five.png" width="100"/>);
  74. doc.write(<img src="../four.jpg" width="100" height="100" alt="four"/>);
  75. doc.write(<img src="../three.png" width="100" height="100" alt="three"/>);
  76. doc.write(<img src="../two.png" width="100" height="100" alt="two"/>);
  77. doc.write(<img src="../one.png" width="100" height="100" alt="one"/>);*/
Add Comment
Please, Sign In to add comment