Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function canMove(x,y){
- var direction = rovers[actualRover].direction;
- switch(direction){
- case 'N':
- if(grid[x - 1][y] === 'obstacle'){
- console.log('Ups! You can't forward in this direction, there is a obstacle.');
- return false;
- }else if(grid[x - 1][y].includes('rover')){
- console.log('Ups! You can't forward in this direction, there is an another Rover.');
- return false;
- }else if(grid[x - 1] <= 0){
- console.log('Ups! You can't exit outside of area!');
- return false;
- }else if(grid[x - 1][y] === null){
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement