Friday, March 13, 2015

7DRL Day 7

Finished! The final version is on the game's website. Here's an announcement thread on Reddit.

Today was devoted to polish, and I ended up adding some animation.

Last night I ran the game past a couple of my friends, which highlighted how poor the feedback was for monster movement and attacking. After trying various things to indicate without animation who had attacked, or where they'd moved from (I tried motion-blurred icons!), I decided I really needed to bite the bullet and do some animation. It's something I have not really figured out a good solution for in my roguelike library.

The technique I opted for here is dirt-simple. You can register a callback with the library for updates, which happen every 5 milliseconds. When time advances in the game, I set a frame counter and register an update callback. (It's 12 frames, I think right now, so pretty quick.) Each update, the frame counter is decremented and the screen is invalidated so it'll get redrawn. On redraw, the frame counter is converted into a percent-done amount, and the characters use this to position themselves as some simple functions of time. Once the frame counter hits zero, the update callback is unregistered, which causes the roguelike library to go to sleep until the next Windows message. Thus it doesn't use any CPU time. (I don't have ongoing incidental animation in the game.)

Sitting still the game looks about the same as yesterday:

Adding animation exposed a nasty bug in my movement code. The pathfinder was returning a set of coordinate pairs: the guy at this position moves to that position, etc. The problem is that the pathfinding code can return a pair of moves (A --> B) and (B --> C). If you process those in that order, you end up with two people at position B after processing the first order. The lookup is indeterminate for handling the second order; you might get the guy who was originally at A, or you might get the guy who was at B. In the non-animated version it didn't matter since all monsters are interchangeable, but with animation it was glaringly obvious when someone moved from A to C in one turn.

Besides animation, I did some other chores like putting in a help and credits screen. I also did some ongoing renaming of stuff in the code, from its origins as a sci-fi extravaganza to its current theme. (The level is still called a planet, though.)

It's been a fun week, and I'm hugely relieved that I got a fun game out of it. In the middle of the week I wasn't sure I'd be able to come up with something interesting. I'll probably talk more about this tomorrow, but it really has been a miniature version of a full game cycle. The wild ideas, the drastic cuts, the race to the finish, etc.

No comments: