Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. // Creating variables
  2. var myX=0,myY=0,grid=[],robotX=[],robotY=[];
  3.  
  4. robotX=[9];
  5. robotY=[9];
  6.  
  7. for (var i=0;i<20;++i){
  8. grid[i]=[];
  9. for (var j=0;j<20;++j){
  10. grid[i][j]=0;
  11. }
  12. }
  13.  
  14. function update() {
  15. myX=myX+(mouseX-myX)/10;
  16. myY=myY+(mouseY-myY)/10;
  17. }
  18. function draw() {
  19. // This is how you draw a rectangle
  20. for(i=0;i<20;i=i+1){
  21. for(j=0;j<20;j=j+1){
  22. if(grid[i][j]==0){
  23. context.fillStyle="gray";//izbor na cvqt
  24. context.fillRect(i*30,j*30,29,29);
  25. }
  26. }
  27. }
  28. }
  29. function keyup(key) {
  30. // Show the pressed keycode in the console
  31. console.log("Pressed", key);
  32. }
  33. function mouseup() {
  34. // Show coordinates of mouse on click
  35. console.log("Mouse clicked at", mouseX, mouseY);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement