Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. //! Pong Tutorial 1
  2.  
  3. use amethyst::{
  4. prelude::*,
  5. renderer::{
  6. plugins::{RenderFlat2D, RenderToWindow},
  7. types::DefaultBackend,
  8. RenderingBundle,
  9. },
  10. utils::application_root_dir,
  11. };
  12.  
  13. pub struct Pong;
  14.  
  15. impl SimpleState for Pong {}
  16.  
  17. fn main() -> amethyst::Result<()> {
  18. amethyst::start_logger(Default::default());
  19.  
  20. let app_root = application_root_dir()?;
  21. let display_config_path = app_root.join("config").join("display.ron");
  22.  
  23. let asset_dir = app_root.join("assets");
  24.  
  25. let mut world = World::new();
  26.  
  27. let game_data = GameDataBuilder::default()
  28. .with_bundle(
  29. RenderingBundle::<DefaultBackend>::new()
  30. // The RenderToWindow plugin provides all the scaffolding for opening a window and drawing on it
  31. .with_plugin(
  32. RenderToWindow::from_config_path(display_config_path)
  33. ?.with_clear([0.0, 0.0, 0.0, 1.0]),
  34. )
  35. // RenderFlat2D plugin is used to render entities with a `SpriteRender` component.
  36. .with_plugin(RenderFlat2D::default()),
  37. )?;
  38.  
  39. let mut game = Application::new(asset_dir, Pong, game_data)?;
  40.  
  41. game.run();
  42.  
  43. Ok(())
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement