SHARE
TWEET

Untitled

a guest Dec 14th, 2014 739 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <canvas id="ctx" width="500" height="500" style="border:1px solid #000000;"></canvas>
  2.  
  3. <script>  
  4. var ctx = document.getElementById("ctx").getContext("2d");
  5. ctx.font = '30px Arial';
  6.  
  7. var x = 50;
  8. var spdX = 30;
  9. var y = 40;
  10. var spdY = 5;
  11.  
  12. setInterval(update,500);
  13.  
  14. function update(){
  15.         x += spdX;
  16.         y += spdY;
  17.         ctx.fillText('P',x,y);
  18.         console.log('hello',x);
  19.        
  20.         if(x > 500){
  21.                 console.log('Out of Bounds');
  22.         }
  23.        
  24. }
  25.  
  26. </script>
RAW Paste Data
Top