Skip to main content

run

Function run 

Source
pub fn run<G: Game>(
    config: Config,
    init: impl FnOnce(&mut InitContext<'_, G>) -> Result<G, Error> + Send + '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 104-107)
103fn main() {
104    run(
105        Config::new("Mirage: stress preview").with_size(1280, 720),
106        StressPreview::init,
107    );
108}
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/flock-parallelism.rs (lines 757-762)
756fn main() {
757    run(
758        Config::new("Mirage: flock parallelism")
759            .with_size(1280, 720)
760            .with_assets([BUTTERFLY_SOURCE]),
761        Flock::init,
762    );
763}
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}