Thursday, December 17, 2009

If it was so easy, why did it take me so long?

Taking a step out of my naration for a moment, you might remember that I stopped working on TinyGame a while back because I was having difficulty with bugs regarding map changing code.

Now, I've finally abstracted everything to the correct level so I have a world, which contain a number of maps, which contain a number of tiles that can hold a number of things, of which one may be a creature (which may also be holding things). Some of those tiles can be stair tiles, which when walked over and activated bring the player to a new map. It sounds so simple, doesn't it?

It certainly didn't turn out simple. After I abstracted from just having maps to having a world containing maps, my player class exploded to no longer wanting to be a creature. I had to rewrite the player class almost from scratch to fix that, and I'm still not even sure why that happened, and am deathly afraid of setting it of again.

Then, I had to come up with a way that the staircases weren't considered items, nor quite terrain, nor creatures. They needed to be something new, and now they take the place of a tile instead of occupying it.

Finally, I needed a way to keep the game, when the player moved from one map to another, from a) displaying the whole game and b)keeping the camera on the player (because other than the fact that it is controlled externally, it's just another creature as far as the game is concerned). I solved that with a little flag on the map that the player is on. Basically, it says 'this map draws'. Combined with art being so much more computationally intensive than the rest of the code, and everything else the game is still running quite smootly with a few monsters running around, and four layers of mps for them to run around on.

Next, I integrate the map generation back onto the maps!

No comments:

Post a Comment