mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-16 20:35:02 +01:00
Initial commit
Basic skeleton
This commit is contained in:
commit
d5c9e24201
6 changed files with 514 additions and 0 deletions
45
src/app.rs
Normal file
45
src/app.rs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
use sfml::{
|
||||
graphics::{Color, RenderTarget, RenderWindow},
|
||||
window::Event,
|
||||
};
|
||||
|
||||
use crate::graphics;
|
||||
|
||||
/// Application level state (includes game and ui state, etc.)
|
||||
pub struct App {
|
||||
rw: RenderWindow,
|
||||
should_quit: bool,
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
rw: graphics::make_window(),
|
||||
should_quit: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn do_game_loop(&mut self) {
|
||||
while !self.should_quit {
|
||||
self.do_event_handling();
|
||||
self.do_update();
|
||||
self.do_rendering();
|
||||
}
|
||||
}
|
||||
|
||||
fn do_event_handling(&mut self) {
|
||||
while let Some(ev) = self.rw.poll_event() {
|
||||
match ev {
|
||||
Event::Closed => self.should_quit = true,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn do_update(&mut self) {}
|
||||
|
||||
fn do_rendering(&mut self) {
|
||||
self.rw.clear(Color::BLACK);
|
||||
self.rw.display();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue