Monday, January 28, 2008

Speech bubbles

I'm experimenting with dumping animated GIFs of the game:

Click on the picture to see the movie. The frames are being played back at a steady rate rather than at the rate of play, so it can be hard to make out what's going on. Here's a summary:

The thief starts in his cabin aboard a ship docked outside the city walls. He disembarks and heads towards the city gates. Before reaching them, however, he is spotted by a patrolling member of the city guard, who opens the portcullis and gives chase. Diving into the harbor to escape capture, the thief swims underwater a short distance before climbing back out. Unfortunately he emerges under the light of a street lamp and is spotted again. The guard pursues him back aboard the ship, but the thief is able to hide under a table in the aft cabin. The guard, who did not see him hide under there, eventually gives up and leaves.

Meanwhile, you can see miscellaneous mutterings from other guards inside the city. I haven't implemented any sound attenuation yet, so whenever anyone says anything you see it.

The guards say lines when they spot the player, when they lose sight of the player, when they arrive at the last spot where they saw the player, and when they return to patrolling. They also randomly say lines while patrolling. This last part is clearly the weakest and needs lots of thought and improvement. (And better lines: That's what she said!)

Here's another, larger movie demonstrating the theft of some gold from the Temple of Theron (named after a local weatherman and not the South African actress):

The thief reads the sign while waiting for the outer patrol to pass. The door is locked with a simple three-pin lock that takes only a handful of turns to pick. Once the door is open, he discovers an inner guard passing nearby. By following close behind the guard he is able to circle to the far end of the temple without being spotted. He reads a hymn in passing before nabbing the gold.

There's still a ton left to be done on this game. At the moment I am focusing on getting good guard behavior. A big part of that is using guard speech to communicate what they are sensing and doing.

Speech needs to be presented visually. My inspiration is comic book speech bubbles. There are a couple of problems: positioning them, and ensuring that they don't flash by too quickly to be read.

Positioning speech bubbles is similar to map labeling which has a variety of algorithms available. I'm thinking of trying simulated annealing.

Up until now the game has not had any real-time animation, although I plan to add some for accent effects like screen transitions, blood spatters, water splashes, and gold sparkles. The game updates every time the player presses a key. If a speech bubble is associated with a given turn it can go by very quickly when the player is pressing keys quickly, or holding down a key and using the keyboard auto-repeat.

Many games in the Roguelike tradition require the player to dismiss text messages using the Space bar. I find this somewhat cumbersome so I'm looking for a way to avoid it. Andrew Doull, who is developing Unangband, came up with his own solution to this, which is to accumulate messages for the turn on-screen starting at the top line and working downward. You can press a key to dismiss them without taking a turn, but you can also press any of the keys you would ordinarily use to make a move and it will both take a turn and clear that frame's messages. I've tried out the latest build of Unangband and it has the problem that messages can flash by too quickly to be read. There is a message history window, accessed by pressing Ctrl-P, but if you have to use this on a regular basis it seems like a failure of the user interface to me.

One feature I'd like to add eventually is undo/redo capability. This would serve the purpose of a message history since you could rewind time to see what you missed. Again, though, the interface should not require regular use of this just to see what's going on.

I'm going to try halting the keyboard auto-repeat whenever a popup speech bubble appears. This should fix the problem of a held key making turns go by too quickly. It may also be annoying, though. It also doesn't address the problem of a player pressing keys very quickly, as they might when they are trying to maneuver in a direction other than a straight line.

Other ideas: Deadly Rooms of Death, a charming turn-based puzzle game, plays out speech bubbles in real time. The conversations thus occur in a separate timeline from the gameplay. This works when they aren't integrally linked to gameplay, but in my situation the guards' speech indicates their internal state, so speech needs to be coupled to the game's turns.

I've thought about accumulating messages over multiple turns based on how much real time has elapsed. Each message would have an on-screen duration, and would remain in the visible message queue for that much real time, regardless of how many turns have elapsed.

I'll be trying out various things like this to see what the benefits and drawbacks are. If you've got any other ideas, send 'em in!

No comments: