web-sys-main-loop

Crates.ioweb-sys-main-loop
lib.rsweb-sys-main-loop
version0.1.8
sourcesrc
created_at2024-01-14 13:03:06.668832
updated_at2024-01-14 16:34:41.50206
descriptionProvides a main loop (or game loop) for web_sys windows
homepage
repositoryhttps://github.com/arongeo/web-sys-main-loop
max_upload_size
id1099415
size26,306
(arongeo)

documentation

README

Crates.io Version Crates.io License docs.rs

web-sys-main-loop

web-sys-main-loop as per the name suggests provides a main loop (in game development communities often called a game loop), for web-sys based WASM pages, with also providing input handling.

Documentation

Example

use web_sys_main_loop::FrameState;
...
let window = web_sys::window().unwrap();
...
web_sys_main_loop::start(&window, move |frame_state: FrameState| {
    ...
    // Gets the position (X, Y) of the cursor in the window
    // context
    let curr_position = frame_state.mouse_state.get_position();
    ...
});
Commit count: 0

cargo fmt