Giter Club home page Giter Club logo

crankstart's Introduction

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:

  1. Follow the setup for crank with Rust nightly's no_std support.
  2. Start a new rust library project with cargo new --lib project_name
  3. git clone [email protected]:pd-rs/crankstart.git at the same depth as your new project.
  4. 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.22.9", default-features = false, features = [ "libm" ] }
hashbrown = "0.14.0"

[dependencies.cstr_core]
version = "=0.1.2"
default-features = false
features = [ "alloc" ]
  1. Add a Crank.toml at the same level as your Cargo.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.

  1. Inside your lib.rs, you only need to implement the crankstart::Game trait to your game's core state struct, then call crankstart::crankstart_game! on that struct. See the examples folder for examples.
  2. To run the project, from its root, you should now be able to crank run successfully!

If you want an example of an independent project following these conventions, go check out Nine Lives.

Updating Bindings

If there's a newer Playdate SDK available that updates the C API, the crankstart bindings should be updated to match. Here's a guide.

  1. Install the dependencies for bindgen.
  2. Install bindgen-cli.
  3. Install the gcc-arm-none-eabi toolchain, either manually or through a system package, which may also be named something like "cross-arm-none-eabi-gcc".
  4. On Linux, install the 32-bit glibc development package, which will be called something like glibc-devel-32bit.
  5. Install the new Playdate SDK, and if it's not at the default MacOS path, set PLAYDATE_SDK_PATH to where you unzipped it. (This should be the directory that contains C_API, CoreLibs, etc.)
  6. Run ./scripts/generate_bindings.sh
  7. Inspect the changes to crankstart-sys/src/bindings_* - they should reflect the updates to the Playdate C API. If nothing changed, double-check that the C API actually changed and not just the Lua API.
  8. Submit a PR with the changes :)

crankstart's People

Contributors

rtsuk avatar boozook avatar lyonbeckers avatar tjkirch avatar someonetoignore avatar parasyte avatar paulyoung avatar tehsmeely avatar adamsoutar avatar jcornaz avatar lilyinstarlight avatar floppydisck avatar pomettini avatar bravely avatar javier-varez avatar ruin0x11 avatar ttencate avatar sam-dillin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.