Here is my code. This level is very buggy and frequently returns true when it’s actually the opposite. Thanks for the help you can offer. @AnSeDra @dedreous @Deadpool198 @brooksy125
// Escape from the maze!
// Some doors are blocked, some open when you are near them.
var distanceBetweenRooms = 16;
var startRoom = {x: 18, y: 19};
var clearUp = function () {
if (hero.isPathClear(hero.pos, {'x': hero.pos.x, 'y': hero.pos.y + 16})) {
return true;
}
};
var clearRight = function () {
if (hero.isPathClear(hero.pos, {'x': hero.pos.x + 16, 'y': hero.pos.y})) {
return true;
}
};
var clearLeft = function () {
if (hero.isPathClear(hero.pos, {'x': hero.pos.x - 16, 'y': hero.pos.y})) {
return true;
}
};
var clearDown = function () {
if (hero.isPathClear(hero.pos, {'x': hero.pos.x, 'y': hero.pos.y - 16})) {
return true;
}
};
var moveUp = function () {
hero.moveXY(hero.pos.x, hero.pos.y + 16);
};
var moveLeft = function () {
hero.moveXY(hero.pos.x - 16, hero.pos.y);
};
var moveRight = function () {
hero.moveXY(hero.pos.x + 16, hero.pos.y);
};
var moveDown = function () {
hero.moveXY(hero.pos.x, hero.pos.y - 16);
};
while(true) {
if (clearLeft() && clearRight() && clearUp() && clearDown()) {
moveRight();
} else if (clearUp()) {
moveUp();
} else if (clearRight()) {
moveRight();
} else if (clearDown()) {
moveDown();
} else if (clearLeft()) {
moveLeft();
}
}