1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
mod engine;
pub use engine::Engine;
pub mod input;
use std::error::Error;
pub use sdl2::{
pixels::Color,
rect::{Point, Rect},
render::WindowCanvas,
};
pub type UpdateResult = Result<bool, Box<dyn Error>>;
pub trait Application {
fn on_update(
&mut self,
canvas: &mut WindowCanvas,
input: &input::InputState,
elapsed_time: f64,
) -> UpdateResult;
fn on_quit(&mut self) -> Result<(), Box<dyn Error>> {
Ok(())
}
}
pub mod prelude {
pub use crate::{
input::{InputState, MouseButton, Scancode},
Color, Point, Rect, WindowCanvas,
};
}