Skip to content

Instantly share code, notes, and snippets.

@videlais

videlais/maze.js Secret

Last active January 2, 2016 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save videlais/7987edbfca668501816f to your computer and use it in GitHub Desktop.
Save videlais/7987edbfca668501816f to your computer and use it in GitHub Desktop.
var x = 1;
var y = 1;
$posx = 1;
$posy = 1;
macros['navigate'] =
{
handler: function(obj, fnc, val)
{
x = $posx; y = $posy;
if(maze[y-1][x] eq 1) {
$North = 1;
} else if(maze[x][y+1] eq 2) {
$Exit = 1;
} else {
$North = 0;
}
if(maze[y+1][x] eq 1) {
$South = 1;
} else if(maze[x][y-1] eq 2) {
$Exit = 1;
} else {
$South = 0;
}
if(maze[y][x-1] eq 1) {
$West = 1;
} else if(maze[x-1][y] eq 2) {
$Exit = 1;
} else {
$West = 0;
}
if(maze[y][x+1] eq 1) {
$East = 1;
} else if(maze[x+1][y] eq 2) {
$Exit = 1;
} else {
$East = 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment