8 releases
0.1.8 | Jan 14, 2024 |
---|---|
0.1.7 | Jan 14, 2024 |
#846 in Game dev
79 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–9.5MB
~174K SLoC