Skip to main content

run

Function run 

Source
pub fn run<G: Game>(
    config: Config,
    init: impl FnOnce(&mut InitContext<'_, G>) -> Result<G, Error> + 'static,
)
Expand description

Opens the window and runs the game init builds until it is closed.

init runs once the GPU exists; returning Err aborts startup.

Blocks on the desktop; passes control to the browser’s event loop and returns there. Errors that stop startup are reported to the standard error stream, or to the console and a page overlay in the browser.

Examples found in repository?
examples/input-lab.rs (lines 531-534)
530fn main() {
531    run(
532        Config::new("Mirage: every control as an action"),
533        InputLab::init,
534    );
535}
More examples
Hide additional examples
examples/stress-preview.rs (lines 103-106)
102fn main() {
103    run(
104        Config::new("Mirage: stress preview").with_size(1280, 720),
105        StressPreview::init,
106    );
107}
examples/post-effects.rs (lines 169-172)
168fn main() {
169    run(
170        Config::new("Mirage: screen effects").with_size(1280, 720),
171        PostEffectEffects::init,
172    );
173}
examples/sound-lab.rs (lines 114-119)
113fn main() {
114    run(
115        Config::new("Mirage: sound lab")
116            .with_size(1280, 720)
117            .with_assets(ASSET_FILES),
118        SoundCheck::init,
119    );
120}
examples/breakout-game.rs (lines 158-163)
157fn main() {
158    run(
159        Config::new("Mirage: breakout game")
160            .with_size(1280, 720)
161            .with_assets([MODEL].into_iter().chain(SOUNDS)),
162        Breakout::init,
163    );
164}
examples/animation.rs (lines 1045-1050)
1044fn main() {
1045    run(
1046        Config::new("Mirage: animation")
1047            .with_size(WINDOW_WIDTH, WINDOW_HEIGHT)
1048            .with_assets([ELF_SOURCE, BUTTERFLY_SOURCE]),
1049        Scene::init,
1050    );
1051}