Dragonfly Sprite Specification

Sprite files must be in an ASCII or UTF text file. Every sprite consists of a header and a body. The file must end with an empty line

Simple Sprites

The first 5 lines of the document are the file header. The following table describes the file header for simple sprites:

Line Number Value Type Description
1 Frame count Integer > 0 The number of animation frames in the sprite
2 Sprite width Integer > 0 The width of the sprite in characters
3 Sprite height Integer > 0 The height of the sprite in characters
4 Slowdown Integer >= 0 The number of frames that each animation frame will last. 0 means “no automatic animation”. 30 would be 1 frame per second because dragonfly runs at 30 frames per second.
5 Sprite color “red” | “yellow” | “green” | “cyan” | “blue” | “magenta” | “white” | “black” The color of the sprite.

Example Header

2
5
3
5
white

Body

The remainder of the file is the body of the sprite file. Every line must be the length of the sprite width defined in the header. The number of lines in the body must be Sprite height * Frame count.

Example Simple Sprite

2
5
3
5
white
  |  
 |-| 
  |  
 /-\ 
|---|
 \-/ 

Advanced Sprites

Header

The header must be surrounded by header tags on their own lines: <HEADER> and </HEADER>. Each of the header values must be defined using their key-value pairs on separate lines. The following is a list of header variables:

Value key Type Description
Frame count frames Integer > 0 The number of animation frames in the sprite
Sprite width width Integer > 0 The width of the sprite in characters
Sprite height height Integer > 0 The height of the sprite in characters
Slowdown slowdown Integer >= 0 The number of frames that each animation frame will last. 0 means “no automatic animation”. 30 would be 1 frame per second because dragonfly runs at 30 frames per second.
Sprite color color “red” | “yellow” | “green” | “cyan” | “blue” | “magenta” | “white” | “black” The color of the sprite.
Transparency transparency Character The character in the sprite file which will be ignored during rendering.

Example Header

<HEADER>
frames 2
width 5
height 3
color white
slowdown 5
transparency #
</HEADER>

Body

The body must be surrounded by body tags on their own lines: <BODY> and </BODY>. Each frame is separated by the keyword end on its own separate line. Every line of a sprite frame must be the length of the sprite width defined in the header. The number of lines in the body must be (Sprite height + 1) * Frame count to include end after each frame.

Example Body

<BODY>
##|##
#|-|#
##|##
end
#/-\#
|---|
#\-/#
end
</BODY>

The footer must be surrounded by footer tags on their own lines: <FOOTER> and </FOOTER>. Each of the footer values must be defined using their key-value pairs on separate lines. The following is a list of header variables: |Value|key|Type|Description| |—|—|—|—| |Format version|version|1|The version number of the sprite file format being used|

<FOOTER>
version 1
</FOOTER>

Example Advanced Sprite

<HEADER>
frames 2
width 5
height 3
color white
slowdown 5
transparency #
</HEADER>
<BODY>
##|##
#|-|#
##|##
end
#/-\#
|---|
#\-/#
end
</BODY>
<FOOTER>
version 1
</FOOTER>

Tips

When creating a new sprite, it is often easiest to take an existing sprite file and modify it.

If there are errors when a sprite file is loaded into the engine (via RM.loadSprite()), Dragonfly will write a message to dragonfly.log. Look for the line number where the parsing may have failed - the error could be there or in the heading specification.

A common error when creating a sprite is having spaces at the end of the line - these don’t show up in the editor but need to be there to “pad” a line in the frame.


IMGD3000 Home IMGD3000 Home