Although the icon graphics are probably the most limiting part of the BYOND system, they are still pretty functional components. Each icon may have an arbitrary number of states; for instance, a humanoid icon could have "sitting", "walking", and "sleeping" states. Each state may have any number of frames to comprise an animation, as well as multiple directions to describe the different facings. Moreover, objects themselves may be associated with multiple icons, overlaying or underlaying them to form a more detailed image. And, of course, the world itself makes provisions for different icon effects, such as projected images and interpolated movement. All of this may be a bit daunting, so we'll attempt to explain some of the procedures here.
Let us lead by example. Open the icon file, ghost.dmi, contained in the sample project:
This icon contains three states:
You can right-click or double-click on each of the states to edit them. The first two states have been defined as movies, meaning that they have multiple directions and/or multiple frames. The death state is just a single pixmap. You can change the dimensionality of a state through the right-click menu.
The editing process for both movies and pixmaps is fairly self-explanatory, and further covered in Dream Maker's documentation, so we won't elaborate here. Essentially it just boils down to double-clicking on the state or frame that you would like to edit, drawing or importing the picture, and repeating.
The only subtle detail is the treatment of the states themselves. By default, assigned icons will use the empty state, "". Suppose we attach the icon with the following code:
In our example, this state is special, because it is also
defined to have the movement property enabled. This is represented by
the little M next to the state name in the editor, and can be toggled by
selecting the "Edit state" option.
Movement state animations get played as their parent objects move between adjacent tiles. This is in contrast to normal animations, which get played continuously. Typical movement states will therefore be animations of walking motions. Since ghosts don't walk, per se, we've decided to make things a little clearer by just having our guy blink (memories of pac-man, anyone?) Notice the effect as the ghost moves around. If you toggle the movement state off, you'll see this effect regardless of movement.
Icon states can be changed at compile- or run-time with the
icon_state property.
For instance, when our mob dies we may want to switch to the "corpse" state:
Another way to use states is to temporarily "flick" them onscreen. This causes one iteration of the state animation to be played:
Sometimes even the ability to transition icons isn't enough. You may want to
instead augment existing icons. While DM doesn't yet provide fine-tune
manipulation (ie- on a pixel-by-pixel or colormap level), it does allow you to
merge icons by overlaying them with other icons. For instance, suppose we want
to show that a mob is injured by displaying a red X on top of its icon:
overlays[] (and underlays[])
lists that can be used to display icons above and below the main icon.
This can be used for special effects as well as enhancements such as
clothing overlays.
Just like the main icon, overlays and underlays will be displayed to all mobs
in view. Sometimes you want to make a graphic that is displayed only to
certain targets. For example, in many games objects may be selected by
clicking on them. Usually you'll only want the selection to be visible to the
player doing the clicking. You can manage this with the image()
command:
Images are drawn in the topmost layer (above mobs). They should mainly be used for these kinds of player-specific effects, since overlays manage global effects more cleanly and efficiently.
Finally, we conclude with a nifty little aside. Did you know that icons can be displayed within text? DMScript provides a convenient macro for the purpose:
This will display the icon next to the player's name in the text. The embedded icon object can be treated just like a piece of text, so with a little innovation you can even make it into a link (perhaps to send a personal message to that player). Sounds like good fodder for another tutorial!