8 releases
0.1.8 | Jan 14, 2024 |
---|---|
0.1.7 | Jan 14, 2024 |
#1045 in Game dev
61 downloads per month
17KB
190 lines
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();
...
});
lib.rs
:
web-sys-main-loop provides a main loop (or game loop), and input handling, for a web_sys window.
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();
...
});
Dependencies
~7.5–10MB
~182K SLoC