You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
629 B
28 lines
629 B
//! Basic window setup code
|
|
|
|
use crate::{ctx, state::ClientState, GameSettings};
|
|
use ggez::{
|
|
event::{self, EventHandler, EventLoop},
|
|
Context,
|
|
};
|
|
|
|
pub struct Window {
|
|
ctx: Context,
|
|
eloop: EventLoop<()>,
|
|
}
|
|
|
|
impl Window {
|
|
pub fn ctx(&mut self) -> &mut Context {
|
|
&mut self.ctx
|
|
}
|
|
|
|
pub fn run(self, state: impl EventHandler + 'static) -> ! {
|
|
event::run(self.ctx, self.eloop, state)
|
|
}
|
|
}
|
|
|
|
/// Start the main event loop with game settings and state
|
|
pub fn create(settings: &GameSettings) -> Window {
|
|
let (ctx, eloop) = ctx::build(settings).build().unwrap();
|
|
Window { ctx, eloop }
|
|
}
|
|
|