Advanced graphics for Inform 7

Interactive fiction’s basic spatial model, with its emphasis on discrete container-spaces, more or less does away with theexperience of travel. The player zips instantaneously between rooms, and while this works pretty well in most indoor spaces, there can be a certain sense of loss, especially when the “room” represents a wide field, a vast hall, or a long street. The character of these spaces depends in large part on the ways in which we move through them–the sense of space & distance, passing time, shifting vistas & perspective, and the people, plants, and things we might interact with while we’re advancing. IF’s instamovement sucks this experiential element out of travel, and thus robs IF authors of a powerful tool for presenting fictional worlds.

I’ve been thinking about ways to bring the experience of travel into IF, and particularly of how to do so with minimal changes to existing conventions. The experiment I’m posting today makes no change at all to the underlying spatial model: There are three rooms, each representing a segment of street in an imaginary city. When the player types walk to <a location>, however, the game doesn’t move him on immediately. Instead, short messages are meted out in real time, describing the changing space, people met on the street, etc. After a few of these messages are displayed, the player is moved into the next room, and another set of messages appropriate to that room are displayed. The process continues until the player arrives at the destination. Click here to play through the example.

As a technique, I think it works reasonably well; I hope that the rather dull text of the example doesn’t detract too much. Though I’ve presented the example using only text, it would work nicely using a graphical map that indicated the real-time steps through animation; a moving dot or icon, for example (this isn’t quite as difficult as it might sound!) Of course, there are potentially a number of  things that would need to be further worked out or refined, depending on how you wanted to use this in an actual game. How to deal with randomized environmental messages, for example, or NPC movement…

Note: In contrast to the earlier tutorial on the Basic Floorplan Toolkit, this tutorial is mostly code-based. It is intended for newcomers to Glimmr who have a basic level of familiarity with Inform 7. While the tutorial touches on the creation of graphics, no real detail is provided and the user’s familiarity with graphics software is assumed. You may want to download the source code, images, and design files before beginning. The images and design files are in the public domain and may be freely used or modified for use in any project; please let me know if you use them!

One of the most common, and most enduring, symbols of interactive fiction has been the compass rose. It provides the logo for the annual IFComp, the IF Archive, and even the loading progress graphic for the javascript Quixe interpreter. As a symbol, the compass rose suggests traditional IF’s focus on maps and exploration, but of course it also literally represents the medium’s standard means of navigating by means of compass direction. Over the last 10 or 15 years, games such as Arrival and Bronze have been exploiting the form of the compass rose to provide an exit lister–an at-a-glance display of the exits available from the player’s current location. For obvious reasons, most of these compass rose/exit listers have been text-based (see the mini-screenshot below), using characters arranged in a grid. But there have been graphical implementations as well, such as the one in Emily Short’s City of Secrets.

The text-based compass rose from Emily Short's BronzeThe text-based compass rose/exit lister from Emily Short’s Bronze. Red letters indicate that the player has not yet visited the room in that direction.

In this tutorial, we’ll be creating a hybrid compass rose and exit lister using Glimmr Canvas-Based Drawing. Here’s what our exit lister will do: It will show, on a compass rose, the directions available to the player from the current location, and it will also indicate (via a yellow halo or highlight) whether the room in a given direction has yet to be visited. For completeness, there will also be a supplementary rosette to handle the non-compass directions (up, down, in, and out). Finally, and because it requires virtually no additional effort, we will also allow the player to click on any valid exit on the compass to issue the appropriate movement command.

The complete compass rose

The end result of this tutorial, running in Gargoyle.

Read the rest of this entry »

UPDATE: It seems that I manage to bungle something with each and every Glimmr package release. For release 3, I managed to revert most of the extensions to version 1. Thanks to Jason Devlin (author of wonderful games like Vespers and Sting of the Wasp), I’ve now realized my mistake and uploaded a new package–Release 3.1 Release 3.2. Sorry, folks!

UPDATE II: It looks like Inform 6G60 also broke one of Glimmr’s dependencies. Release 3.2 includes a modified version of Michael Callaghan’s Fixed Point Maths extension.

A new zip archive of all the Glimmr extensions, image files, and compiled examples is available at the Google Code site. This archive is compatible with the new Inform build, 6G60, and brings Glimmr Canvas Editor up to date as well (that is, compatible with both 6F95 and 6G60). A number of bugs were fixed, primarily in Glimmr Canvas Editor, but there are no major changes or additions.

This release actually involves changes to only two of the extensions: Glimmr Canvas Editor and Glimmr Automap. Both of these should show up soon for individual download from the Inform 7 extensions site.

The Compiled Examples zip archive has also been updated to Release 3, and can be downloaded from the Google Code site. This is only useful for demo purposes, as all of the files are also available in the full release archive.

Happy New Year!

UPDATE 11/3/2011: Glimmr Form Fields is now available in release 3 of the full Glimmr release zip archive, as well as at the Inform 7 extensions library.

I’ve finally come to the end of a rather quixotic quest. A strange bug bit me while I was finishing up the main Glimmr package a few months back: I wanted to leverage Glimmr’s capabilities to create a relatively easy way for authors to offer HTML-style form fields within an IF game. Why on earth did I want to do that? Not for any good reason; in fact, I still haven’t come up with a practical IF-related use for it that would justify the hours it eventually took from me! Other than perhaps to remake Bureaucracy (see image below for a form from that game).

Screenshot of color picker

A simple RGB color calculator made with Glimmr Form Fields

In the end, I had to create two extensions to accomplish this goal: Glimmr Form Fields and Glulx Input Loops. (If you’re curious about the form fields, you can download compiled example games here; this will let you see how it works without firing up Inform 7, installing dependencies–of which there are many–etc. See the note about interpreters below.) A short discussion of how the one led to the other follows.

The basic mechanics for graphic form fields were easy and I was able to put a prototype together in just a few hours. I had good, general-purpose yet customizable ways to control text entry into the field, the backspace key, moving the cursor within the field, and so on. This rested (and still rests) on a couple of subterfuges: First, of course, the “text” in the form fields is not actually text but individual letterform graphics strung together to form words. Second, one doesn’t type really anything “into” the text fields; instead, we are receiving per-character input in the main text window and converting that for display in the graphics window.

Pre-HTML form fields from Infocom's Bureaucracy, by Douglas Adams (screenshot by Moby Games user Belboz)

It was the latter that caused me real headaches. Not because it was difficult to create something basic, but because I wanted the user (player) to be able to interact with multiple fields, clicking on one to type and then clicking on another to enter text there. Inform’s built-in input routines are very simply structured, and this turned out to be a sticky problem: Multiple fields easily led to nested loops that would quickly crash the program, or lead to other difficulties.

So, I had to make a bit of detour, and get an education in the finer points of Glulx input and Inform 7‘s (and Inform 6′s) implementation of input (special thanks to Zarf, the creator of Glulx, for his help–and patience). In the end, I decided to more or less rewrite the library input routines. Without going into great detail, the Glulx Input Loops extension gives the author many more hooks for decision-making within the overall “loop” of input to action-processing. It also introduces named input loops, as well as the idea of the “secondary” input loop, which shares input-handling with the “primary” loop; this goes a good way toward preventing the kinds of nasty nesting problems that can result when some types of input spawn new requests for input.

A diagram of primary vs secondary input loops

A (perhaps somewhat cryptic to the uninitiated) flowchart showing the relationship between primary and secondary input loops as defined in the Glulx Input Loops extension.

The new hooks provided by Glulx Input Loops let me complete Glimmr Form Fields as I wanted, avoiding the issues with event nesting. Glulx Input Loops also resulted in the keystroke input experiment I posted a month or so back. I hope that it proves to be a useful extension, and I think it will, particularly to those experimenting with alternate input paradigms.

I’m still asking myself why I dedicated myself to implementing form fields, though. The end result is pretty neat, but its neatness is not really IF-related… Who knows, maybe someone will think of something to do with it; the tool is there, at least. In the meantime, if you have your any ideas for using Glimmr Form Fields in IF, please feel free to leave a comment below–I’d love to hear that someone might actually get some use out of it!

A note for Mac users who might want to check out the Glimmr Form Fields compiled examples: If you are using a Mac, you probably default to using Zoom or Spatterlight as your interpreter of choice. Neither is a good fit for Glimmr, however. The current version of Zoom (1.1.4.1) has a few bugs that impact heavily on Glimmr games, while Spatterlight is too old to have taken advantage of recent advances in speed (or bugfixes). Please consider downloading Gargoyle instead. (Gargoyle is also recommended for Linux and Windows users, though the latter have the option of Windows Glulxe/Windows Git.)

A minimalist exercise with Glimmr Form Fields, showing just one field.

A minimal implementation of Glimmr Form Fields.

UPDATE 1/3/2011: Glimmr Canvas Editor has now been updated and a new full release archive (release 3) of Glimmr has been posted at the Google Code site.

Inform build 6F95 has been released. This release of Inform is primarily a maintenance release, but it still required quite a few changes in the Glimmr extensions. Updated versions of all of the Glimmr extensions have now been submitted to the extensions library, except for Glimmr Canvas Editor (which requires Dynamic Objects, which has not yet been updated for 6F95).

If you prefer, you can also download them directly from the SVN repository, or by browsing the source here (click on the “view raw file” link on each extension’s page). You can also get Glimmr Automap and Glimmr Form Fields as separate 6F95-compatible archives on the downloads page.

A zip archive of all extensions and related image resources will be released when Glimmr Canvas Editor is updated.

While working on another project, I found that I really needed much more control over Inform’s input loops. I put together an extension to solve the problem, Glulx Input Loops. While the primary impetus for GIL was rather arcane, the final extension also allows for the game’s primary input loop to accept any type of input in place of “line input” (the standard typed text input familiar in interactive fiction). For example, if you want your game to be played entirely with hyperlinks—no typing at all—you could make that change by writing, essentially, a single line (you’d also have to include one of the numerous extensions that implement hyperlink input).

Anyway, while contemplating what kind of example code I could include with this extension, I thought about the way that Nethack has you chain together single keystroke inputs to build commands. For example, to eat something, you key in “e” for “eat”, followed by another letter for the edible inventory item you’re keen on. I wondered whether something similar might work for interactive fiction, and so I threw together a quick experiment to explore the question.

The result is a bit underimplemented—you can only enter, at most, VERB + NOUN inputs—and there quite a few issues are left hanging that any full-scale game would need to address, such as how to provide contextual lists of items, how to allow the player to refer to things outside her immediate environs, how to handle conversation, and so on. Still, it at least gives a good sense of how this kind of thing could work. You can play the example online, browse the source, or download a gblorb for use on your favorite desktop interpreter here:

Under Doom (An Interactive Experiment)

Reflection: I’m not sure whether this fills any real need. A similar interface that used hyperlinks would be more practical for mobile devices, for example, and for most of us working on a full-size computer, typing a full word isn’t really a whole lot less work than hitting a single key. Comments welcome.

UPDATE 1/3/2011: The newest version of Glimmr Automap (v3) is now available, with image assets, as part of the full Glimmr release archive (get it here), and should soon be available from the Inform 7 extensions site. The Automap zip archive mentioned below has been withdrawn.

It seems that the zip archive I posted last week for Glimmr Automap was missing some necessary image files in the automap tileset. A new archive has been posted on the project’s Google Code page. Get the updated archive.

UPDATE 1/3/2011: The newest version of Glimmr Automap (v3) is now available, with image assets, as part of the full Glimmr release archive (get it here), and should soon be available from the Inform 7 extensions site. The Automap zip archive mentioned below has been withdrawn.

Glimmr Automap, an extension for Inform 7, is now available. The extension, its accompanying tileset, compiled examples, and image files can be downloaded in a single package here. Note that Glimmr Automap will initially be provided as a separate download from the main Glimmr package, but will be rolled into the main package at the next release. (If you don’t already have the main Glimmr package, you will need to download a number of other Glimmr extensions in order to use Glimmr Automap. You can get the other Glimmr extensions one by one here, or download them all at once here.)

Glimmr Automap screenshot

Glimmr Automap. Click for full-size image.

Glimmr Automap, unlike the other Glimmr extensions, is essentially a plug-and-play solution: Including it in your project will give you a complete graphical map (of the flowchart style) that reveals itself to the player as he or she explores the game world. (The truly hard work is done by Mark Tilford’s Automap extension, which generates the map data that powers Glimmr Automap.) Various customizable interface extras are included: the player can zoom into or out of the map, open and close the map window, and—if a text-painting font is installed—can also click on a room in the map to see that room’s name in a “tooltip”.

The individual tiles of the tileset.

The individual tiles of the provided tileset.

The examples included with the extension add other capabilities: clicking on a room in the map moves the player to that room, or clicking on an exit from the PC’s current location moves the player in the direction of that exit (a bit like a compass rose surrounding the room on the map).

The map data is rendered using tilesets composed of individual graphic files. One such tileset is included along with Glimmr Automap (the Glimmr Automap Tileset), and authors can create their own tilesets. Tilesets are distributed as extensions (plus tile images, of course).The original Illustrator art for the Glimmr Automap Tileset is included to provide a starting point for authors looking to create their own look.

The full Glimmr download package includes a compiled file, Basic Floorplan Toolkit.gblorb, that is intended to allow authors to produce floor plans for (indoor) interactive fiction games. The Basic Floorplan Toolkit is an instance of the Glimmr Canvas Editor that is preloaded with a set of images representing rooms, hallways, stairways, and doors. The floor plans that the Toolkit produces are based on the feelie maps Emily Short produced for her game Bronze. The design is quite simple, but it also gets us a good way beyond your purely functional box-and-line IF map. Here’s an example:

Floor plan for a portion of Emily Short's Bronze

Floor plan for a portion of Emily Short's Bronze. Room names expunged to avoid spoilers.

As with other instances of the Canvas Editor, you build your floor plan visually in Basic Floorplan Toolkit, and then export Inform 7 source code which, when pasted into your game, will recreate your composition. If you tweak a few things while setting up your plan, the map will be self-revealing, with each room appearing on the map only after the player has visited it. You can also set up a little Parcheesi piece to represent the player, and its movement through the map will be automated.

Detailed instructions for the use of the Canvas Editor can be found in that extension’s documentation. This tutorial is intended to allow interested folks to get into using the Basic Floorplan Toolkit with a minimum of background reading. You can download a game file (gblorb format) of the map we will be creating here.
Read the rest of this entry »

Glimmr released

Glimmr, a set of extensions for use with Inform 7 and the subject of this occasional blog, has finally been released. For the uninitiated, Inform is software for writing interactive fiction, otherwise known as “text adventures,” using English-like sentences. Inform can compile to the Glulx virtual machine, which allows for graphics, sound, and other features. But Inform’s native support for these features is quite meager, and Glimmr is an attempt to bring Inform’s support for graphics up to the level of Glulx’s potential.

Glimmr is a modular system of extensions. Several of these extensions can be used independently of other Glimmr modules, but they gain additional capabilities when used in conjunction. The bedrock extension, Glimmr Drawing Commands, provides basic instructions to draw a wide variety of entities, from simple rectangles, to external images files (PNG or JPEG), to bitmaps and even painted text. Here are some representative drawing commands:

Representative drawing commands available using Glimmr

Other extensions are what we might call “data” extensions, which don’t themselves provide new functionality. Fonts and tilesets are distributed in this way. Examples include Glimmr Bitmap Font and Glimmr Image Font.

But the core of Glimmr is the Canvas-Based Drawing extension. This module supplies a complete screen model for graphics windows, using the notion of the “canvas”. Graphic elements–anything that can be drawn using Glimmr Drawing Commands, or any new command the user wishes to invent–are assigned to a canvas. The canvas can then be shown in a graphics window. The scaling and the framing of the canvas within the window can be controlled, and canvases can be swapped out at will. It is easy to specify the layering of elements on the canvas, so that in effect graphics can be displayed along three axes (x, y, and z). Canvas-Based Drawing allows for complex and dynamic compositions to be created relatively quickly. The Glimmr Graphic Hyperlinks extension automates the handling of mouse input to any element.

Glimmr ships with another extension, built on Canvas-Based Drawing, called the Glimmr Canvas Editor. The Canvas Editor is meant to be compiled as an independent project, not as a part of another game, and it produces a complete GUI graphics editor that can be used to draw elements of various types to a canvas, visually. Once the canvas is complete, you can export it as Inform source code for use with Canvas-Based Drawing. Special features are included to deal with canvases that change over time, such as maps that dynamically reveal themselves as the player discovers new locations in the game.

Download Glimmr.

Follow

Get every new post delivered to your Inbox.