Friday, December 30, 2011

Doors




Well, we are in the midst of the holidays. Everyone is sick. And work is getting ready to gear up for the New Year crunch. I finally had a moment at a coffee shop this last week, while waiting for someone, and got in a quick 20 minutes on the WishfulRPG! That's the true beauty and fun of this ridiculous project. It's only 20 minutes stints.

Doors. I implemented doors.

They are a deceptively tricky game feature to do. They essentially amount to all sorts of special case code dependent on events and so forth, but this is exactly the kind of feature you want to implement to see if your game code is structured correctly.

In short, mine isn't. Yet. But I know what to fix. For now, it works, and working goes a long, long way when you are rapidly prototyping things. You are better off throwing things together quickly and getting them working, than spending hours or days or weeks pontificating on elegant designs.

Partially, this is because elegant designs unveil themselves with experience. And partially because when making digital creations, we are not making physical castles. It's easy to change things and throw things out (provided you haven't accrued too much code debt.) It's also very easy to over design something before you build it.

So doors are working, crapfully.

The problem is that all the terrain is tiles, but a tile is just a sprite that can be rendered. And there is a collision model provided by pygame. Really, what we want is a snap-together component model for game objects. That is to say, you can add on the ability to collide to an object. Or an object can be a tile. And it can be a trap. And a animated particle system. And it can play a unicorn fart noise when the avatar steps on it. Etc and so on.

So this means a fundamental rewrite and some foundation work to get a component system going for all these attributes and event responses and so forth. But I am going to put that off, and instead implement some portcullises, and sliding blocks, and triggers and other things. In a nasty and messy way. This should let me have an idea of just how I want everything to be cleaned up. So once I have some non-trivial stuff working, then we can fit it to a more elegant weapon for a civilized age. I should probably put a mob in there as well.

No comments:

Post a Comment