Skip to main content

mireforge_boot_advanced_game/
lib.rs

1/*
2 * Copyright (c) Peter Bjorklund. All rights reserved. https://github.com/mireforge/mireforge
3 * Licensed under the MIT License. See LICENSE in the project root for license information.
4 */
5use int_math::UVec2;
6use limnus::prelude::{App, AppReturnValue, DefaultPlugins, ScreenMode, Window};
7use mireforge_advanced_game::audio::GameAudioRenderPlugin;
8use mireforge_advanced_game::logic::GameLogicPlugin;
9use mireforge_advanced_game::render::GameRendererPlugin;
10use mireforge_advanced_game::{ApplicationAudio, ApplicationLogic, ApplicationRender};
11use mireforge_font::FontPlugin;
12use mireforge_material::MaterialPlugin;
13use mireforge_render_wgpu::plugin::RenderWgpuPlugin;
14
15// #[must_use] // TODO: should be able to convert AppReturnValue in the future
16#[must_use]
17pub fn run_advanced<L: ApplicationLogic, R: ApplicationRender<L>, A: ApplicationAudio<L>>(
18    title: &str,
19    virtual_size: UVec2,
20    requested_surface_size: UVec2,
21) -> AppReturnValue {
22    App::new()
23        .insert_resource(Window {
24            title: title.to_string(),
25            requested_surface_size,
26            minimal_surface_size: virtual_size,
27            mode: ScreenMode::Windowed,
28        })
29        .add_plugins((DefaultPlugins, RenderWgpuPlugin, MaterialPlugin))
30        .add_plugins(GameRendererPlugin::<R, L>::new())
31        .add_plugins(GameLogicPlugin::<L>::new())
32        .add_plugins(GameAudioRenderPlugin::<A, L>::new())
33        .add_plugins(FontPlugin)
34        .run()
35}