wasm4

Crates.iowasm4
lib.rswasm4
version0.2.0
sourcesrc
created_at2021-12-16 14:46:23.735943
updated_at2024-04-07 09:09:45.746615
descriptionWASM-4 bindings for Rust
homepage
repositoryhttps://github.com/ZetaNumbers/wasm4-rs
max_upload_size
id499215
size30,897
Daria Sukhonina (zetanumbers)

documentation

README

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 }
Commit count: 84

cargo fmt