This commit is contained in:
unintendedfraud
2024-01-27 22:47:22 +01:00
parent 227c0021fe
commit 6e7ab861c9
5 changed files with 95 additions and 54 deletions
+42
View File
@@ -0,0 +1,42 @@
mod map;
mod player;
mod prelude {
pub use bracket_lib::prelude::*;
pub use crate::map::*;
pub use crate::player::*;
pub const SCREEN_WIDTH: i32 = 80;
pub const SCREEN_HEIGHT: i32 = 50;
}
use prelude::*;
struct State {
map: Map,
player: Player,
}
impl State {
fn new() -> Self {
return Self {
map: Map::new(),
player: Player::new(Point { x: SCREEN_WIDTH / 2, y: SCREEN_HEIGHT / 2 }),
};
}
}
impl GameState for State {
fn tick(&mut self, ctx: &mut BTerm) {
ctx.cls();
self.player.update(ctx, &self.map);
self.map.render(ctx);
self.player.render(ctx);
}
}
fn main() -> BError {
let context = BTermBuilder::simple80x50().with_title("Dungeon Crawler").with_fps_cap(30.0).build()?;
return main_loop(context, State::new());
}