Skip to content

Instantly share code, notes, and snippets.

@Pretz
Last active December 11, 2015 21:18
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 Pretz/4661320 to your computer and use it in GitHub Desktop.
Save Pretz/4661320 to your computer and use it in GitHub Desktop.
collisionMatrix = new boolean[160][90];
Pixmap backgroundMap = new Pixmap(Gdx.files.internal("data/warehouse-map.png"));
for (int y = 0; y < 90; y++) {
for (int x = 0; x < 160; x++) {
// Get the pixel, shifting off the alpha value
int pixel = backgroundMap.getPixel(x, y) >>> 8;
if (pixel == 0x000000) {
// true means impassible, also invert y to match our coordinate system
collisionMatrix[x][90 - y] = true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment