Draft 01/27/2024
This is a draft of the codebase on the date reflected above.
This commit is contained in:
39
vash_caster/src/lib.rs
Normal file
39
vash_caster/src/lib.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
extern crate rand;
|
||||
extern crate sdl2;
|
||||
|
||||
mod caster;
|
||||
use caster::Caster;
|
||||
|
||||
use sdl2::event::Event;
|
||||
use sdl2::keyboard::Keycode;
|
||||
|
||||
use std::error::Error;
|
||||
use std::time::Duration;
|
||||
|
||||
pub fn run() -> Result<(), Box<dyn Error>> {
|
||||
let sdl_context = sdl2::init()?;
|
||||
let video_subsystem = sdl_context.video()?;
|
||||
|
||||
let mut caster = Caster::init(&video_subsystem, "Vash Caster", 800, 600)?;
|
||||
|
||||
let mut event_pump = sdl_context.event_pump()?;
|
||||
|
||||
'running: loop {
|
||||
for event in event_pump.poll_iter() {
|
||||
match event {
|
||||
Event::Quit { .. }
|
||||
| Event::KeyDown {
|
||||
keycode: Some(Keycode::Escape),
|
||||
..
|
||||
} => break 'running,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
caster.update()?;
|
||||
|
||||
::std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 144));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user