Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Creating variables
- var myX=0,myY=0,grid=[],robotX=[],robotY=[];
- robotX=[9];
- robotY=[9];
- for (var i=0;i<20;++i){
- grid[i]=[];
- for (var j=0;j<20;++j){
- grid[i][j]=0;
- }
- }
- function update() {
- myX=myX+(mouseX-myX)/10;
- myY=myY+(mouseY-myY)/10;
- }
- function draw() {
- // This is how you draw a rectangle
- for(i=0;i<20;i=i+1){
- for(j=0;j<20;j=j+1){
- if(grid[i][j]==0){
- context.fillStyle="gray";//izbor na cvqt
- context.fillRect(i*30,j*30,29,29);
- }
- }
- }
- }
- function keyup(key) {
- // Show the pressed keycode in the console
- console.log("Pressed", key);
- }
- function mouseup() {
- // Show coordinates of mouse on click
- console.log("Mouse clicked at", mouseX, mouseY);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement