Merchant Seas Game
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

56 行
1.6 KiB

  1. // modules
  2. mod states;
  3. // namespacing
  4. use amethyst::{
  5. core::transform::TransformBundle,
  6. input::{InputBundle, StringBindings},
  7. prelude::*,
  8. renderer::{
  9. plugins::{RenderFlat2D, RenderToWindow},
  10. types::DefaultBackend,
  11. RenderingBundle,
  12. },
  13. ui::{RenderUi, UiBundle},
  14. utils::application_root_dir,
  15. };
  16. fn main() -> amethyst::Result<()> {
  17. // enable engine logging
  18. amethyst::start_logger(Default::default());
  19. // set up root dir
  20. let app_root = application_root_dir()?;
  21. // define assets dir
  22. let assets = app_root.join("assets");
  23. // set up display configuration
  24. let display_config = app_root.join("config").join("display_config.ron");
  25. let render_to_window =
  26. RenderToWindow::from_config_path(display_config)?.with_clear([1.0, 1.0, 1.0, 1.0]);
  27. // set up keybindings configuration
  28. let bindings = app_root.join("config").join("bindings_config.ron");
  29. let input_bundle = InputBundle::<StringBindings>::new().with_bindings_from_file(bindings)?;
  30. // initialize the game data struct
  31. let game_data = GameDataBuilder::default()
  32. // bundle inclusion
  33. .with_bundle(TransformBundle::new())?
  34. .with_bundle(input_bundle)?
  35. .with_bundle(UiBundle::<StringBindings>::new())?
  36. .with_bundle(
  37. RenderingBundle::<DefaultBackend>::new()
  38. .with_plugin(render_to_window)
  39. .with_plugin(RenderUi::default())
  40. .with_plugin(RenderFlat2D::default()),
  41. )?;
  42. // create and run the game
  43. let mut game = Application::new(assets, states::preload_state::PreloadState, game_data)?;
  44. game.run();
  45. Ok(())
  46. }