wasm-game-lib

Welcome!

The goal of this crate is to help you to make great 2d games running in web browsers. This crate is very similar to SFML. To use this crate, you will have to use wasm-pack. You can install wasm-pack with:

cargo install wasm-pack

To create your game crate, the best way is to use: wasm-pack new

Then, put this crate on Cargo.toml as usual. You can now compile the crate with: wasm-pack build --target=web

I suggest you put this on lib.rs and add the crate wasm-bindgen-futures.

```rust

[allow(unused_imports)]

use wasmbindgen::{prelude::*, JsCast}; use wasmgamelib::graphics::image::Image; use wasmgamelib::graphics::sprite::Sprite; use wasmgamelib::inputs::event::Event; use wasmgamelib::graphics::window::Window; use wasmgamelib::system::log; use wasmgamelib::inputs::event::types::*; use wasmgame_lib::system::sleep; use std::time::Duration;

[wasm_bindgen(start)]

pub async fn start() -> Result<(), JsValue> { let (mut window, mut canvas) = Window::initwithevents(MOUSEEVENT + KEYBOARDEVENT + RESIZEEVENT + FOCUSEVENT);

// load images and fonts here
// you could make a progress bar

loop {
    for event in window.poll_events() {
        // do something with events
        log(&format!("{:?}", event));
    }

    canvas.clear();
    // canvas.draw(&object);

    sleep(Duration::from_millis(16)).await;
}

Ok(())

} ```

License: MIT