Wednesday, August 7, 2013

Serializing levels for the win

I've decided it's high time that I rebuild the triggers in the code.  I've made so many changes to how I think they should work that it now requires a major rewrite, just like what I'm going to have to do for the levels pretty soon here.

So I dig into it.  Since I'm serializing the levels through the editor instead of writing a line in a text file for the level, I can just pull grab the object.  I recreated the code that creates a trigger and took a look at it.  9 lines total.  Curious, I looked at the original code.  105 lines with a helper function that is another 20 lines.  This makes the code much easier to use, and much easier to modify.  In the future, I'm just going to use xml serialization instead of trying to read in the text and determining what goes where and what changes have been made that breaks other things.

Currently the LoadLevel code is 555 lines long.  Excited to see how much smaller I can make that!

No comments:

Post a Comment