main.rs 845 B

12345678910111213141516171819202122
  1. use ggez::GameError;
  2. fn main() -> Result<(), GameError> {
  3. let (mut ctx, mut evloop) = ggez::ContextBuilder::new("game", "me")
  4. .add_resource_path({
  5. let base = std::env::var("CARGO_MANIFEST_DIR").unwrap();
  6. let mut path = std::path::PathBuf::from(base);
  7. path.push("resources");
  8. path
  9. })
  10. .window_mode(ggez::conf::WindowMode {
  11. width: 80.0 * 8.0,
  12. height: 50.0 * 8.0,
  13. ..ggez::conf::WindowMode::default()
  14. })
  15. .build()?;
  16. let tileset = carpet::Tileset::from_file(&mut ctx, [8, 8], "/terminal8x8.jpg")?;
  17. let mut board = carpet::Board::new([80, 50], tileset);
  18. board.print([1, 1], "Hello, world!");
  19. let mut game = carpet::Game::create("game", "me", board)?;
  20. ggez::event::run(&mut ctx, &mut evloop, &mut game)
  21. }