This commit is contained in:
nora 2023-04-17 22:04:44 +02:00
parent a55aedca0c
commit 39dde35229
2 changed files with 33 additions and 42 deletions

View file

@ -1,39 +0,0 @@
use crate::{
command::CmdVec,
debug::{self, DebugState},
game::GameState,
res::Res,
};
use egui_sfml::SfEgui;
/// Application level state (includes game and ui state, etc.)
pub(crate) struct App {
pub(crate) game: GameState,
pub(crate) res: Res,
pub(crate) sf_egui: SfEgui,
pub(crate) debug: DebugState,
/// Integer scale for rendering the game
pub(crate) scale: u8,
pub(crate) cmdvec: CmdVec,
}
impl App {
pub(crate) fn new() -> anyhow::Result<Self> {
loop {}
}
pub(crate) fn do_game_loop(&mut self) {
self.do_rendering();
}
fn do_rendering(&mut self) {
self.sf_egui
.do_frame(|ctx| {
debug::do_debug_ui(
ctx,
&mut self.debug,
&mut self.game,
&mut self.res,
&mut self.scale,
&mut self.cmdvec,
);
})
.unwrap();
}
}

View file

@ -1,4 +1,9 @@
mod app;
use command::CmdVec;
use debug::DebugState;
use egui_sfml::SfEgui;
use game::GameState;
use res::Res;
mod command;
mod debug;
mod game;
@ -8,9 +13,34 @@ mod res;
mod texture_atlas;
mod tiles;
mod world;
use app::App;
pub(crate) struct App {
pub(crate) game: GameState,
pub(crate) res: Res,
pub(crate) sf_egui: SfEgui,
pub(crate) debug: DebugState,
/// Integer scale for rendering the game
pub(crate) scale: u8,
pub(crate) cmdvec: CmdVec,
}
impl App {
pub(crate) fn new() -> anyhow::Result<Self> {
loop {}
}
}
fn main() {
let mut app = App::new().unwrap();
app.do_game_loop();
app.sf_egui
.do_frame(|ctx| {
debug::do_debug_ui(
ctx,
&mut app.debug,
&mut app.game,
&mut app.res,
&mut app.scale,
&mut app.cmdvec,
);
})
.unwrap();
}