|
- // modules
- mod states;
-
- // namespacing
- use amethyst::{
- core::transform::TransformBundle,
- input::{InputBundle, StringBindings},
- prelude::*,
- renderer::{
- plugins::{RenderFlat2D, RenderToWindow},
- types::DefaultBackend,
- RenderingBundle,
- },
- ui::{RenderUi, UiBundle},
- utils::application_root_dir,
- };
-
- fn main() -> amethyst::Result<()> {
- // enable engine logging
- amethyst::start_logger(Default::default());
-
- // set up root dir
- let app_root = application_root_dir()?;
-
- // define assets dir
- let assets = app_root.join("assets");
-
- // set up display configuration
- let display_config = app_root.join("config").join("display_config.ron");
- let render_to_window =
- RenderToWindow::from_config_path(display_config)?.with_clear([1.0, 1.0, 1.0, 1.0]);
-
- // set up keybindings configuration
- let bindings = app_root.join("config").join("bindings_config.ron");
- let input_bundle = InputBundle::<StringBindings>::new().with_bindings_from_file(bindings)?;
-
- // initialize the game data struct
- let game_data = GameDataBuilder::default()
- // bundle inclusion
- .with_bundle(TransformBundle::new())?
- .with_bundle(input_bundle)?
- .with_bundle(UiBundle::<StringBindings>::new())?
- .with_bundle(
- RenderingBundle::<DefaultBackend>::new()
- .with_plugin(render_to_window)
- .with_plugin(RenderUi::default())
- .with_plugin(RenderFlat2D::default()),
- )?;
-
- // create and run the game
- let mut game = Application::new(assets, states::preload_state::PreloadState, game_data)?;
- game.run();
-
- Ok(())
- }
|