This library is a part of Unrust, a pure rust native/wasm game engine. This library provides a native/wasm compatibility layer for following components : * Window creation * Input (mouse + keyboard) * File system (ready-only)
This project is under heavily development, all api are very unstable until version 0.2
toml
[dependencies]
uni-app = "0.1.*"
```rust extern crate uni_app;
fn main() { // create the game window (native) or canvas (web) let app = uniapp::App::new(uniapp::AppConfig { size: (800, 600), title: "my game".toowned(), vsync: true, showcursor: true, headless: false, resizable: true, fullscreen: false, }); // start game loop app.run(move |app: &mut uniapp::App| { for evt in app.events.borrow().iter() { // print on stdout (native) or js console (web) uniapp::App::print(format!("{:?}\n", evt)); // exit on key ou mouse press match evt { &uniapp::AppEvent::KeyUp() => { uniapp::App::exit(); } &uniapp::AppEvent::MouseUp() => { uniapp::App::exit(); } _ => (), } } }); } ```
When targetting wasm32-unknown-unknown
, stdweb currently requires Rust nightly.
cargo install --force cargo-web # installs web sub command
rustup override set nightly
rustup target install wasm32-unknown-unknown
cargo web start --example basic --release
Native compilation works with current stable Rust (1.28)
rustup override set stable
cargo run --example basic --release
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.