pub fn run_with_event_handler<T, F1, F2>(
event_loop: EventLoop,
input: InputMap<T>,
settings: Settings,
event_handler: F2,
logic: F1,
) -> Result<(), EventLoopError>
Expand description
used to quickly set up logic. handles closed and input events for you. the logic
var will be
run every frame. the event_handler
var is
for if you want more control over the event handling and is run multiple times before logic.
use thin_engine::prelude::*;
let (event_loop, window, display) = thin_engine::set_up().unwrap();
#[derive(Hash, PartialEq, Eq, Clone, Copy)]
enum Actions{
Debug
}
use Actions::*;
let mut input = input_map!(
(Debug, KeyCode::Space)
);
thin_engine::run_with_event_handler(
event_loop, input,
Settings::default(),
|event, input, settings, target| {
match event {
//do something with events
_ => ()
}
}, |input, settings, target|{
let mut frame = display.draw();
frame.clear_color(0.0, 0.0, 0.0, 1.0);
frame.finish().unwrap();
});