SHARE
TWEET

Untitled

a guest Jun 18th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function canMove(x,y){
  2.   var direction = rovers[actualRover].direction;
  3.  
  4.   switch(direction){
  5.     case 'N':
  6.     if(grid[x - 1][y] === 'obstacle'){
  7.       console.log('Ups! You can't forward in this direction, there is a obstacle.');
  8.       return false;
  9.     }else if(grid[x - 1][y].includes('rover')){
  10.       console.log('Ups! You can't forward in this direction, there is an another Rover.');
  11.       return false;
  12.     }else if(grid[x - 1] <= 0){
  13.       console.log('Ups! You can't exit outside of area!');
  14.       return false;
  15.     }else if(grid[x - 1][y] === null){
  16.       return true;
  17.     }
  18.   }
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top