Tuesday, May 17, 2011

More Databases, and Weather?

So, unfortunately nothing visual to show today. The last few days have seen some serious under-the-hood-type work instead.

Database Stuff
After last week's foray into the world of databases, it was time to use that newfound knowledge to get my game reading data from mySQL rather than hard-coded values. Getting flash to load data turned out to be a little tricky, as it was a non-linear process. It involved a lot of kicking off queries and listening for events signalling their finish. And with lots of data to load, that meant lots of disorganized listeners on my first draft.

After some rethinking, I setup a more organized DataHandler class which could dispatch queries to loader classes and store the results for the rest of the game to use later. Furthermore, I managed to simplify the game start-up process such that I could just list all the steps in one place, and let the DataHandler execute them in order, listeners and all.

The result? The hex types, their settings, and all game images are loaded from mySQL! It's pretty cool to be able to add data to the database now and not have to recompile. The closest I've been before was XML serialization routines in C#, which are also good, but I thought mySQL would be a better fit for lots of data writing.

Oh, and I managed to expand my database setup webpage to now include buttons for managing the game database, including recreating it based on the specifications in the php page. I was making enough changes to the database table structures that having this saved me significant time already. Guess the tech artist in me isn't retired yet :)

Other Bulletproofing
I also spent a bunch of time restructuring classes and methods to be more reliable, and more organized. Normally, I'd leave this for later, in the spirit of rapid-prototyping. But occasionally, one needs to do some housecleaning to make existing code easier to expand on for the next features. For example, I was rewriting code to handle getting the Hex under the mouse enough times that I decided to make it a method and be done with it.

Indie Life Continues
Still on the same daily schedule. The three 2-hour blocks are working quite well, and the afternoon grocery run with Rochelle is proving a welcome stretch and reinvigorator.

I'm managing to stay pretty focused too! Before I started, I was a bit worried I'd be one of those people who needs to unplug the ethernet to avoid stray browsing during work. But so far, I'm pretty on-it when I'm sitting at my desk. I occasionally stare out the window and watch traffic/people, but it tends to be while thinking of solutions to problems.

Next Steps
With that infrastructure work out of the way, I'd like to look into weather. The player is going to be struggling to survive against nature, so let's get some nature in there! I'd like to handle this a lot like the fog of war, in that it should be simple and only "seem" complex. Not exactly sure how I'll handle this yet, but I have a few ideas.

That's it for now. More to come!

No comments:

Post a Comment