Crate musi_lili

Source
Expand description

§musi lili

musi lili is a retro game engine for GB styled games written in Rust. Inspired by pico8.

§How to use this crate

§Add musi_lili to your Cargo.toml file

[package]
name = "my_game"
version = "0.1.0"
edition = "2021"

[dependencies]
musi_lili = { version = "0.3" }

§Create your game

Create a struct that defines your game and implements the musi_lili::Game trait. After that you can start your game by calling musi_lil::run with the type of your game.

use musi_lili::{Game, Lili};

struct MyGame;

impl Game for MyGame {
    fn init(_lili: &Lili) -> Self {
        Self
    }

    fn update(&mut self, _lili: &Lili) {
        // the code to update your game
    }

    fn draw(&mut self, lili: &Lili) {
        // draw your game
        lili.clear(0);
        lili.txt("toki", 5, 5, 3);
    }
}

fn main() {
    musi_lili::run::<MyGame>(musi_lili::load!("my-game"));
}

§Cargo Features

  • std: use rust std (default).
  • gamepad: activate gamepad support (needs libudev to be installed).
  • slint-femtovg: use winit with femtovg renderer as slint backend (default).
  • slint-software: use winit with software renderer as slint backend.
  • experimental: enable this feature to try out experimental features that are not yet ready for production.

§Used third party libraries

LibraryLicenseUsed for
SlintGNU GPlv3, Royalty-free or PaidWindow, framebuffer and event handling
embedded-graphicsApache 2.0 or MITPixel art drawing
dirs-nextApache 2.0 or MITGet user settings path
serdeApache 2.0 or MITSerialize / Deserialize game data
serde-jsonApache 2.0 or MITSerialize / Deserialize game data
gilrsApache 2.0 or MITSupport for game controllers
web-timeApache 2.0 or MITUse Instant::now() on the web
web-sysApache 2.0 or MITUsed for web save game management

Macros§

load
Loads the GameData from $CARGO_MANIFEST_DIR"/assets/name.lili. Creates the file if not exists.

Structs§

Color
Used to define a color for of a custom Palette.
GameData
This struct is used to load and save the data of the game like sprites and map.
Lili
This struct give access to the main api of the musi lili engine.
Point
Describes a point with x ans y.

Enums§

Button
This enum defines an button.
Key
Defines a keyboard key.
Palette
This enum defines all available color palettes.

Constants§

CHAR_HEIGHT
Gets the height of a char in pixel.
CHAR_WIDTH
Gets the width of a char in pixel.
DISPLAY_HEIGHT
Gets the height of the display in pixel.
DISPLAY_WIDTH
Gets the width of the display in pixel.
MAP_HEIGHT
Defines the maximum height of the map in number of sprites.
MAP_WIDTH
Defines the maximum width of the map in number of sprites.
SPRITE_HEIGHT
Gets the height of a sprite in pixel.
SPRITE_WIDTH
Gest the width of a sprite in pixel.

Traits§

Game
Implement this trait for your game.

Functions§

data_from_path
Read GameData from given path, creates the file if not exits.
data_from_str
Reads a json string and convert it to a GameData object.
rgb
Used to generate a Color.
run
save_data
Saves GameData to the given path.
settings_dir
This is a helper function to read the settings directory of the current user depending on the operating system.