4 releases

new 0.1.3 Apr 7, 2024
0.1.2 Jan 17, 2022
0.1.1 Jan 17, 2022
0.1.0 Jan 14, 2022

#8 in #wasm4

Download history 28/week @ 2024-02-25 55/week @ 2024-03-31

55 downloads per month
Used in wasm4

MIT license

29KB
714 lines

WASM4-rs

Idiomatic bindings for WASM-4 in Rust.

WASM-4 is a low-level fantasy game console for building small games with WebAssembly. Game cartridges (ROMs) are small, self-contained .wasm files that can be built with any programming language that compiles to WebAssembly.

Example

#![no_main]

use wasm4 as w4;

struct MyRuntime {
    count: i32,
}

// prints "tick" every second
impl w4::rt::Runtime for MyRuntime {
    fn start(_: w4::rt::Resources) -> Self {
        MyRuntime { count: 0 }
    }

    fn update(&mut self) {
        if self.count % 60 == 0 {
            w4::trace("tick");
            self.count = 0;
        }
        self.count += 1;
    }
}

w4::main! { MyRuntime }

Dependencies

~16MB
~126K SLoC