Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- function openwindow(){
- window.open('Game.html','', 'resizable=no , scrollbars=no , toolbar=no , width=500 , height=600');
- Gamespace();
- }
- function Gamespace(){
- var ball= document.getElementById("ball");
- var intialspeedX= Math.floor(Math.random()*11);
- var intialspeedY= Math.floor(Math.random()*11);
- var ballspeedX = intialspeedX;
- var ballspeedY = intialspeedY;
- var ballX = 200;
- var ballY = 300;
- var time = Date.now();
- var previousframe = Date.now();
- var deltaT = 0;
- var updater = function(){
- previousframe= time;
- time= Date.now();
- deltaT = (time- previousframe)/1000;
- //move the ball
- ballX += ballspeedX * deltaT;
- ballY += ballspeedY * deltaT;
- /*top wall
- if (ballY <=10){
- ballspeedY = -ballspeedY;
- }
- //left
- if (ballY <=10){
- ballspeedX = -ballspeedX;
- }
- //right
- if (ballX >= 480){
- ballspeedX = -ballspeedX;
- }
- //bottom
- if(ballY >= 580){
- ballspeedY = -ballspeedY;
- }*/
- ball.style.left = ballX + "px";
- ball.style.top = ballY + "px";
- }
- setInterval(updater,1000/60);
- }
- //don't mind this stuff
- /*doc.write(<img alt="five" height="100" src="../five.png" width="100"/>);
- doc.write(<img src="../four.jpg" width="100" height="100" alt="four"/>);
- doc.write(<img src="../three.png" width="100" height="100" alt="three"/>);
- doc.write(<img src="../two.png" width="100" height="100" alt="two"/>);
- doc.write(<img src="../one.png" width="100" height="100" alt="one"/>);*/
Add Comment
Please, Sign In to add comment