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 = { git = "https://codeberg.org/vivi-ui/lili", tag = "v0.4" }§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"));
}§Upgrade Guide: v0.3 → v0.4
§Key Change
Starting with v0.4, musi-lili is no longer published on crates.io. You must now reference the project directly from its Git repository.
§Steps to Upgrade
-
Update your
Cargo.toml: Replace the existing dependency with:musi_lili = { git = "https://codeberg.org/vivi-ui/lili", tag = "v0.4" } -
Run
cargo update: Execute the following command in your project directory to fetch the new version:cargo update -p musi_lili -
Rebuild your project: Clean and rebuild to ensure all dependencies are correctly resolved:
cargo clean && cargo build
§Why This Change?
The project is no longer published on crates.io because I no longer maintain a GitHub account, which is required for publishing there. Hosting the project directly on Codeberg aligns better with my workflow and preferences. If you encounter issues, check the project’s issue tracker or open a new issue.
§Cargo Features
std: use rust std (default).gamepad: activate gamepad support (needslibudevto be installed).slint-skia: use winit with skia renderer as slint backend (default).slint-femtovg: use winit with femtovg renderer as slint backend.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
| Library | License | Used for |
|---|---|---|
| Slint | GNU GPlv3, Royalty-free or Paid | Window, framebuffer and event handling |
| embedded-graphics | Apache 2.0 or MIT | Pixel art drawing |
| dirs-next | Apache 2.0 or MIT | Get user settings path |
| serde | Apache 2.0 or MIT | Serialize / Deserialize game data |
| serde-json | Apache 2.0 or MIT | Serialize / Deserialize game data |
| gilrs | Apache 2.0 or MIT | Support for game controllers |
| web-time | Apache 2.0 or MIT | Use Instant::now() on the web |
| web-sys | Apache 2.0 or MIT | Used for web save game management |
Macros§
- load
- Loads the
GameDatafrom$CARGO_MANIFEST_DIR"/assets/name.lili. Creates the file if not exists.
Structs§
- Color
- Used to define a color for of a custom
Palette. - Game
Data - 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
GameDatafrom given path, creates the file if not exits. - data_
from_ str - Reads a json string and convert it to a
GameDataobject. - rgb
- Used to generate a
Color. - run
- save_
data - Saves
GameDatato the given path. - settings_
dir - This is a helper function to read the settings directory of the current user depending on the operating system.