Skip to content

Instantly share code, notes, and snippets.

@jaz303
Created February 3, 2010 14:37
Show Gist options
  • Save jaz303/293643 to your computer and use it in GitHub Desktop.
Save jaz303/293643 to your computer and use it in GitHub Desktop.
public void parseLevel() {
open("level");
while (at("map", "tilesets")) {
if (at("map")) {
open("map");
int width = (int) attr("width");
int height = (int) attr("height");
// alloc map array of width x height
for (int i = 0; i < height; i++) {
open("r");
for (int j = 0; j < width; j++) {
if (at("n")) {
skip(); // skips child nodes too
} else if (at("c")) {
open(); // unconditional open
// read attributes and populate stuff
close();
}
}
close();
}
} else if (at("tilesets")) {
// you get the idea
}
}
close(); // implicit stack, should know i'm trying to close "level"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment