Function run Copy item path 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.
530 fn main() {
531 run (
532 Config::new("Mirage: every control as an action" ),
533 InputLab::init,
534 );
535 }More examples Hide additional examples
102 fn main() {
103 run (
104 Config::new("Mirage: stress preview" ).with_size(1280 , 720 ),
105 StressPreview::init,
106 );
107 }168 fn main() {
169 run (
170 Config::new("Mirage: screen effects" ).with_size(1280 , 720 ),
171 PostEffectEffects::init,
172 );
173 }113 fn main() {
114 run (
115 Config::new("Mirage: sound lab" )
116 .with_size(1280 , 720 )
117 .with_assets(ASSET_FILES),
118 SoundCheck::init,
119 );
120 }157 fn 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 }1044 fn 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 }Additional examples can be found in: