StupidRPG: Output Queue

Input queue, output queue, callback queue…SRPG has all kinds of queues. The output queue is a fun one. On the basic side, it handles the process of outputting text to the browser (paragraphs generated by the player’s action). It does a few more interesting things as well.

Timing

Why a queue? Why not just output all the text immediately. Two reasons: screen management and dramatic timing.

Screen Management

Being a browser game, the dimensions (width and height) of the window in which it’s played are not known to me at design time. In particular, I don’t know how many lines of text will fit on the screen vertically. The output queue lets me ‘pause’ the flow of text when room runs out, and prompt the user to press a key to continue. You might recognize this feature from the classic Infocom games.

Dramatic Timing

This one is more fun. Not all text has to be drawn to the screen at the same speed. Pauses can be inserted between text items at will. This is particularly useful when outputting narration or dialogue, in which moments of hesitation or consideration by the GM or NPCs will make the output feel more lifelike.

Effects

I haven’t made use of this concept yet, but the output queue also allows for the inclusion of special effects down the road. For example, a typewriter output effect, backspacing to erase a typo by the GM, and so forth. Something to look forward to for the next time I don’t have pressing bugs to deal with.