use macroquad::prelude::*;
use crate::scene::{FrameContext, Scene};
pub struct VisualApp<S> {
scene: S,
clear_color: Color,
}
impl<S> VisualApp<S>
where
S: Scene,
{
pub fn new(scene: S) -> Self {
Self {
scene,
clear_color: color_u8!(6, 8, 18, 255),
}
}
pub fn clear_color(mut self, color: Color) -> Self {
self.clear_color = color;
self
}
pub async fn run(mut self) {
loop {
let ctx = FrameContext::gather();
clear_background(self.clear_color);
self.scene.update(&ctx);
self.scene.draw(&ctx);
next_frame().await;
}
}
}