Created
February 3, 2010 14:37
-
-
Save jaz303/293643 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
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