Created
August 19, 2019 20:01
-
-
Save Untrusted-Game/3ae6191745707f4a752a097bc6346f10 to your computer and use it in GitHub Desktop.
Solution to level 2 in Untrusted: http://alex.nisnevich.com/untrusted/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************** | |
* theLongWayOut.js * | |
******************** | |
* | |
* Well, it looks like they're on to us. The path isn't as | |
* clear as I thought it'd be. But no matter - four clever | |
* characters should be enough to erase all their tricks. | |
*/ | |
function startLevel(map) { | |
map.placePlayer(7, 5); | |
var maze = new ROT.Map.DividedMaze(map.getWidth(), map.getHeight()); | |
var maze = new ROT.Map.DividedMaze(map.getWidth()-200, map.getHeight()-200); | |
maze.create( function (x, y, mapValue) { | |
// don't write maze over player | |
if (map.getPlayer().atLocation(x,y)) { | |
return 0; | |
} | |
else if (mapValue === 1) { //0 is empty space 1 is wall | |
map.placeObject(x,y, 'block'); | |
} | |
else { | |
map.placeObject(x,y,'empty'); | |
} | |
}); | |
map.placeObject(map.getWidth()-4, map.getHeight()-4, 'block'); | |
map.placeObject(map.getWidth()-6, map.getHeight()-4, 'block'); | |
map.placeObject(map.getWidth()-5, map.getHeight()-5, 'block'); | |
map.placeObject(map.getWidth()-5, map.getHeight()-3, 'block'); | |
map.placeObject(map.getWidth()-10, map.getHeight()-10, 'exit'); | |
map.placeObject(map.getWidth()-5, map.getHeight()-4, 'exit'); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment