digging/src/state.rs

26 lines
779 B
Rust
Raw Normal View History

2021-03-02 09:55:27 +00:00
use anymap::AnyMap;
use glium::{framebuffer::SimpleFrameBuffer, glutin::event::Event, Display, Frame, Surface};
mod test_state;
pub use test_state::TestState;
2021-03-09 20:51:45 +00:00
use crate::assets::Assets;
2021-03-02 09:55:27 +00:00
pub trait GameState {
2021-03-09 20:51:45 +00:00
fn input(&mut self, assets: &Assets, event: &Event<()>);
fn update(&mut self, assets: &Assets, dt: f32) -> Option<Box<dyn GameState>>;
fn render(&mut self, assets: &Assets, display: &Display, target: &mut SimpleFrameBuffer);
2021-03-02 09:55:27 +00:00
}
pub struct DummyState;
impl GameState for DummyState {
2021-03-09 20:51:45 +00:00
fn update(&mut self, _assets: &Assets, _dt: f32) -> Option<Box<dyn GameState>> {
2021-03-02 09:55:27 +00:00
None
}
2021-03-09 20:51:45 +00:00
fn input(&mut self, _assets: &Assets, _event: &Event<()>) {}
2021-03-02 09:55:27 +00:00
2021-03-09 20:51:45 +00:00
fn render(&mut self, _assets: &Assets, _display: &Display, _target: &mut SimpleFrameBuffer) {}
2021-03-02 09:55:27 +00:00
}