Manual Ship

On this page
  1. CSS sprites
  2. Indexed PNG
  3. Aseprite
  4. Tiled tilesets
  5. Next

Other formats

CSS sprites for web pages, indexed PNGs with a palette file, Aseprite files and Tiled tilesets.

Besides the engines, Mode 8 writes four formats for the web, for retro pipelines and for other tools: CSS sprites, an indexed PNG with its palette, an Aseprite file, and a Tiled tileset for terrain.

Make a starter project to follow along:

bash
mode8 init my-game --template platformer
cd my-game

CSS sprites#

The css format turns a sprite into plain CSS: one class per frame and one per animation, played by CSS keyframes with no script. It also writes a demo page that shows every frame and every animation.

terminal
$ mode8 export assets/hero/frames --out-dir site/sprites --name hero --formats css --animations assets/hero/master.m8.json
✓ Exported hero (15 frames) → site/sprites/
  css · 4 files
  animations attack, hurt, idle, jump, walk
  palette nes_master_gothic from mode8.toml

Next:
  mode8 verify --assets-dir site/sprites

Link the stylesheet and use the classes:

html
<link rel="stylesheet" href="sprites/hero.css">
<div class="m8-hero m8-hero--idle"></div>        <!-- one frame -->
<div class="m8-hero m8-hero--anim-walk"></div>   <!-- the walk, playing -->

.m8-hero sets the frame size and the atlas as the background with pixelated scaling, .m8-hero--<frame> picks a frame, and .m8-hero--anim-<animation> plays an animation at its own speed with steps() timing, so frames snap instead of sliding. A one-shot animation plays once and holds its last frame. Open hero_demo.html in a browser to see them all.

The CSS demo page: the hero's nine frames at 1:1 and each animation playing
hero_demo.html

To show a sprite bigger, scale its element with transform: scale(3) or zoom: 3. The classes set image-rendering: pixelated, so it stays sharp.

Indexed PNG#

The indexed format writes the atlas as an indexed PNG (each pixel stores a palette index; index 0 is transparent) and the palette as a .hex file, one rrggbb color per line starting at index 1. Retro engines, palette-cycling shaders and many pixel-art editors read this pair. Pass the palette whose order the indices should follow:

terminal
$ mode8 export assets/hero/frames --out-dir retro --name hero --formats indexed --palette nes_master_gothic
✓ Exported hero (15 frames) → retro/
  indexed · 4 files
  animations attack, hurt, idle, jump, walk

Next:
  mode8 verify --assets-dir retro
$ head -4 retro/hero.hex
101834
2f2d44
4a4e67
6b748b

The palette order is kept exactly as the palette file lists it. If the art uses pure black for its outline and the palette has no black, black is added as one more entry. The export is strict: a semi-transparent pixel or a color outside the palette stops it with an error naming the colors, rather than writing a PNG that does not match the art. mode8 lint --palette ... --fix repairs such a sprite first; see Checks.

Aseprite#

mode8 aseprite export writes frames into an .aseprite file, with one tag per animation, for an artist who works in Aseprite:

terminal
$ mode8 aseprite export assets/hero/frames --out exports/hero.aseprite
✓ Wrote exports/hero.aseprite (15 frames, 1 layer, 32-bit)
  tags attack, hurt, idle, jump, walk

--color-depth 8 writes an indexed file with --palette embedded, and --fps sets the frame duration (default 8 fps). From a project, --project-root . --asset hero --layered writes an asset's layer stack as real Aseprite layers. Bringing Aseprite files back in is covered in Bring in your art.

Tiled tilesets#

mode8 autotile --formats tiled writes a Tiled tileset (.tsx) next to the autotile sheet. It includes a Wang set, so Tiled's terrain brush picks the right edge and corner tiles as you paint:

terminal
$ mode8 autotile grass --out-dir maps/grass --name grass --formats tiled
✓ Autotile grass: 16 blob16 tiles (16x16) → maps/grass/
  sheet maps/grass/grass_autotile.png
  top-down · grass edges · 8 interior variants
  Tiled maps/grass/grass.tsx
  palette nes_master_gothic from mode8.toml
$ head -6 maps/grass/grass.tsx
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.10.2" name="grass" tilewidth="16" tileheight="16" tilecount="24" columns="4">
 <image source="grass_autotile.png" width="64" height="96"/>
 <tile id="15" probability="0.15"/>
 <tile id="16" probability="0.125"/>
 <tile id="17" probability="0.075"/>

Open the .tsx in Tiled (Map > Add External Tileset), select the grass terrain in the Terrain Sets panel and paint. --formats godot,tiled writes the Godot TileSet as well. Terrain and props covers the tiles, the layouts and the edge styles.

Next#