Loading Order

When Pixel Vision 8 runs a game, each file is loaded in a specific order. Knowing this order is important to understand how a game’s data is parsed by the engine. Here are the steps that Pixel Vision 8 performs when loading a game’s files:

Order

Type

File Name

Description

1

System Data

data.json

This file overrides any default chip settings before anything else is parsed.

2

System Colors

colors.png

All of the colors in this file will replace the default system colors.

3

Color Map

color-map.png

This is stored in a temporary ColorChip and used instead of the system colors for parsing sprites, font, and tilemap PNG files.

4

Sprites

sprites.png

This PNG file is cut up into 8x8 sprites based on the system colors or color map that was previously loaded.

5

Tile Map

tilemap.png or tilemap.json

This file can be a PNG or JSON. If both are present, the json file will be the one that is loaded. When parsing a PNG, you can set a flag that will add any tiles that are not found in the SpriteChip’s memory.

6

Fonts

*.font.png

Each font PNG is cut up into 8x8 sprites and added to the SpriteChip’s memory if there is space. After each font is parsed, references to each character sprite are saved in the FontChip under the font file’s name minus the .font.png extension.

7

Sounds

sound.json

Each sound effect is parsed and stored in the sound chip.

8

Music

music.json

The music file contains songs and patterns. Patterns are collections of sound effects the tracker plays in a specific order and frequency while the songs are collections of patterns.

9

Metadata

info.json

This contains additional information about the game that is not used to configure any of the other parsers.

Once these files are loaded into memory, changes made to them will not be reflected in the game at run-time.

If your project has a code.lua file, it will automatically be loaded as the main game script after the data.json file has been parsed. Any additional .lua files in your project will also be loaded but they are not parsed until you call LoadScript(). This allows you to break your game’s logic up over multiple Lua files. See the section on using Shared Libraries to learn more about how this works.