Project Setup
Note
The words "Stage" and "Backdrop" are used interchangeably in Crust.
Projects are defined by a project.toml
file in the root directory. This file contains metadata about the project, such as allowing debug features, the stages, the sprites and their costumes, etc. Here is an example of a project.toml
file:
debug_options = [ "show_fps", "show_mouse_pos" ]
[stage]
backdrops = [ "backdrop_0.png" ]
[[sprites]]
name = "title"
code = "title/title.crst"
costumes = [ "title/title.png" ]
sounds = []
x = 0
y = 200
w = 1200
h = 300
[[sprites]]
name = "player"
code = "player/player.crst"
costumes = [ "player/player.png" ]
x = 0
y = 0
w = 150
h = 150
[[sprites.sounds]]
name = "jump"
file = "player/jump.wav"
The project.toml
file is written in TOML format, which is a simple and human-readable configuration file format. You can read more about TOML here.
TOML Structure
All paths mentioned are relative to the project.toml
file.
debug_options
: A list of debug options to enable. Only available options areshow_fps
andshow_mouse_pos
show_fps
: Shows the current frames per second (FPS)show_mouse_pos
: Shows the current mouse position on the screen (World coordinates, not screen coordinates)
[stage]
: The stage configurationbackdrops
: A list of backdrops for the stage. If the list is empty, the stage will have an empty backdrop
[sprites]
: A list of sprites in the project[[sprites]]
: A spritename
: The name of the sprite. Can have spaces and special characters. Case-sensitive.code
: The path to the sprite's code file.costumes
: A list of costumes for the sprite. The costumes are images that the sprite can use. If the list is empty, the sprite will have no costumes.[sprites.sounds]
: A list of sounds for the sprite[[sprites.sounds]]
: A soundname
: The name of the sound. Can have spaces and special characters. Case-sensitive.file
: The path to the sound file. Can only be a.wav
file.
x
: The x-coordinate of the sprite. Center is 0, left is negative, right is positive.y
: The y-coordinate of the sprite. Center is 0, up is negative, down is positive.w
: The width of the sprite in pixels. Defaults to 100.h
: The height of the sprite in pixels. Defaults to 100.
The keys debug_options
and [sprites.sounds]
are optional. If they are not present, the default values will be used.
Recommended Project Structure
The recommended project structure is as follows:
project/
|-- project.toml
|-- stages/
| |-- backdrop_0.png
|-- sprites/
| |-- sprite/
| | |-- sprite.crst
| | |-- sprite.png
| | |-- sprite.wav