Crates.io | web-sys-main-loop |
lib.rs | web-sys-main-loop |
version | 0.1.8 |
source | src |
created_at | 2024-01-14 13:03:06.668832 |
updated_at | 2024-01-14 16:34:41.50206 |
description | Provides a main loop (or game loop) for web_sys windows |
homepage | |
repository | https://github.com/arongeo/web-sys-main-loop |
max_upload_size | |
id | 1099415 |
size | 26,306 |
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.
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();
...
});