crankstart
crankstart copied to clipboard
A barely functional, wildly incomplete and basically undocumented Rust crate whose aim is to let you write Games for the Playdate handheld gaming system in Rust.
Rust for Playdate
You've stumbled across a barely functional, wildly incomplete and basically undocumented Rust crate whose aim is to let you write games for the Playdate handheld gaming system in Rust.
This software is not sponsored or supported by Panic.
Installation
To use this crate, you'll also need to install the crank command line tool.
From the crankstart directory where you found this README,
crank run --release --example hello_world
Should launch the simulator and load in the hello_world sample.
If you have a device attached to your desktop,
crank run --release --example hello_world --device
Should launch the hello_world sample on the device.
For the sprite_game example one needs to copy the images folder from "PlaydateSDK/C_API/Examples/Sprite Game/Source/images" to "sprite_game_images".
Your Own Project
Using this system for your own project requires some setup:
- Follow the setup for
crankwith Rust nightly'sno_stdsupport. - Start a new rust library project with
cargo new --lib project_name git clone [email protected]:pd-rs/crankstart.gitat the same depth as your new project.- Go into the new project, and add the following to your
Cargo.toml:
[package.metadata.cargo-xbuild]
memcpy = false
sysroot_path = "target/sysroot"
panic_immediate_abort = false
[profile.dev]
panic = "abort"
opt-level = 'z'
lto = true
[profile.release]
panic = "abort"
opt-level = 'z'
lto = true
[lib]
crate-type = ["staticlib", "cdylib"]
[dependencies]
crankstart = { path = "../crankstart" }
crankstart-sys = { path = "../crankstart/crankstart-sys" }
anyhow = { version = "1.0.31", default-features = false }
euclid = { version = "0.20.13", default-features = false, features = [ "libm" ] }
hashbrown = "0.7.2"
heapless = "0.5.5"
[dependencies.cstr_core]
version = "=0.1.2"
default-features = false
features = [ "alloc" ]
- Add a
Crank.tomlat the same level as yourCargo.toml, with this minimum:
[[target]]
name = "project_name"
assets = [
]
assets should be a list of paths to any/all assets you need copied into your project, such as sprites, music, etc.
- Inside your
lib.rs, you only need to implement thecrankstart::Gametrait to your game's core state struct, then callcrankstart::crankstart_game!on that struct. See theexamplesfolder for examples. - To run the project, from its root, you should now be able to
crank runsuccessfully!
If you want an example of an independent project following these conventions, go check out Nine Lives.