use crate::render::color::Color;
use minifb::{Scale, ScaleMode, WindowOptions};
use std::time::Duration;
#[derive(Clone, Debug)]
pub struct GameConfig {
pub title: String,
pub update_rate_limit: UpdateRate,
pub width: usize,
pub height: usize,
pub fixed_time_step: TimeStamp,
pub window: WindowOptions,
}
impl Default for GameConfig {
#[inline]
fn default() -> Self {
Self {
title: String::from("New Game"),
update_rate_limit: FPS60,
width: 800,
height: 600,
fixed_time_step: TimeStamp::default(),
window: WindowOptions {
borderless: false,
title: true,
resize: true,
scale: Scale::X1,
scale_mode: ScaleMode::AspectRatioStretch,
topmost: false,
transparency: false,
none: false,
},
}
}
}
#[derive(Clone, Debug)]
pub struct TimeStamp(pub Duration);
impl Default for TimeStamp {
#[inline]
fn default() -> Self { Self(Duration::from_secs_f32(1.0 / 60.0)) }
}
pub type UpdateRate = Duration;
pub const FPS30: Duration = Duration::from_nanos(33333333);
pub const FPS60: Duration = Duration::from_nanos(16666666);
pub const FPS120: Duration = Duration::from_nanos(8333333);
pub type Image = Vec<Color>;
#[derive(Clone, Copy, Debug)]
pub enum Button {
Keyboard(minifb::Key),
Mouse(minifb::MouseButton),
}