So what I’ve been working on for the last couple of days is wrapping up all of the info on each map tile into a little container class… Well, let me explain something.
One of the main things I’ve learned about programming is how easy it is to talk yourself into doing really stupid things in the name of being clever. That’s basically where my current level/map storage system came from. Now, there’s nothing intrinsically terrible about what I’ve done — I pack tile information into a bitmap, then I compress it into a png file and save and load it that way. Totally reasonable, right? Especially since Flash has pretty good support for both file IO and modification of image files, I get a lot of utility for free and I can pretty easily pack all the necessary info into an object which, if need be, I can manually modify in photoshop for testing purposes. That’s the clever part. The STUPID part is when I fall in love with that cleverness so much that I neglect to take the obvious step of wrapping the bitmaps representing that tile data with an interface that makes some goddamn sense.
I’ve been working on this project for years, and I still have bits of code where, in the main game class, it’s reading pixels from the game map’s bitmap and manually bitshifting them to perform operations. What the fuck!
So, yeah, I’ve created a MapTile class — underneath the hood, in memory, it’s STILL just an unsigned int with data packed into it. All that the map class needs to do to read or write map info is copy that one uint into and out of a tile object — and, from outside, the tile object provides a bunch of intuitive and easy to grasp accessor variables.
The lesson, I think, it to always pretend that you’re making this for the end user. Even if you’re the only end user — do you want yourself to have to put up with this shit?