Advertisement
Guest User

Untitled

a guest
Oct 12th, 2013
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>something</title>
  5. <script>
  6. var x=20, y=20, r=10;
  7. var ySpeed=1, yAcceleration=1;
  8. var t, g;
  9.  
  10. function begin(){
  11. t=document.getElementById("canvas");
  12. g=t.getContext("2d");
  13. }
  14. function draw(){
  15. g.clearRect(0, 0, t.width, t.height);
  16. g.strokeStyle="red";
  17. g.fillRect(x, y, r, r);
  18. }
  19. function move(){
  20. ySpeed+=yAcceleration;
  21. y+=ySpeed;
  22. draw();
  23. }
  24. function Start(){
  25. ySpeed=document.getElementById('speed').value;
  26. yAcceleration=document.getElementById('acceleration').value;
  27. setInterval("move", 50);
  28. }
  29. </script>
  30. </head>
  31. <body onload="begin()">
  32. <canvas id="canvas" width="300" height="500" style="background-color:yellow"></canvas><br />
  33.  
  34. Speed:<br /><input type="text" id="speed" value="1"/><br />
  35. Acceleration:<br /><input type="text" id="acceleration" value="1"/><br />
  36. <input type="button" value="Start it" onclick="Start()"/>
  37. </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement