6 releases

0.2.0 Apr 7, 2024
0.1.2 Jan 17, 2022
0.0.3 Jan 2, 2022
0.0.2 Dec 16, 2021

#337 in WebAssembly

Download history 1/week @ 2024-02-22 1/week @ 2024-02-29 11/week @ 2024-03-28 114/week @ 2024-04-04 11/week @ 2024-04-11

136 downloads per month

MIT license

30KB
624 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 }

lib.rs:

Examples

Dependencies

~0–2.5MB
~21K SLoC