Created
September 1, 2013 22:25
-
-
Save nevyn/6407724 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <vector> | |
int width = 8, height = 10; | |
struct Tile { | |
bool is_wall; | |
} tiles[height][width]; | |
struct Coordinate { | |
int x, y; | |
}; | |
vector<Coordinate> neighbors(Coordinate current) { | |
vector<Coordinate> neighbors; | |
Coordinate potentials[] = { | |
{current.x, current.y-1}, | |
{current.x, current.y+1}, | |
{current.x-1, current.y}, | |
{current.x+1, current.y}, | |
}; | |
for(int i = 0; i < 4; i++) { | |
Coordinate coordinate = potentials[i]; | |
if(!tiles[coordinate.y][coordinate.x].is_wall) | |
neighbors.push_back(coordinate); | |
} | |
return neighbors; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment