diff --git a/README.md b/README.md index 91ac412..04e8723 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,7 @@ -# scion -Scion is a minimalist, **easy** to use, game engine built on top of legion and miniquad. +Scion Engine + +Scion is a minimalist, **easy** to use, modulable game engine built on top of legion and miniquad. + + + + diff --git a/examples/hello-world/main.rs b/examples/hello-world/main.rs index bdca38c..d7d735f 100644 --- a/examples/hello-world/main.rs +++ b/examples/hello-world/main.rs @@ -1,16 +1,16 @@ use scion::application::Scion; use scion::legion::{system, Resources, World}; use scion::utils::time::Time; -use log::info; +use log::{info}; use scion::utils::window::WindowDimensions; -use scion::config::scion_config::{ScionConfig, ScionConfigBuilder}; -use scion::config::window_config::{WindowConfig, WindowConfigBuilder}; + + use scion::renderer::{RendererType, ScionRenderer}; use miniquad::Context; struct T; impl ScionRenderer for T{ - fn draw(&mut self, context: &mut Context, world: &mut World, resource: &mut Resources) { + fn draw(&mut self, _context: &mut Context, _world: &mut World, _resource: &mut Resources) { unimplemented!() } } diff --git a/src/application.rs b/src/application.rs index 935c19c..a2090c5 100644 --- a/src/application.rs +++ b/src/application.rs @@ -6,7 +6,9 @@ use miniquad::{conf, Context, EventHandlerFree, UserData}; use crate::config::scion_config::{ScionConfig, ScionConfigReader}; use crate::utils::time::Time; use crate::utils::window::WindowDimensions; -use crate::renderer::RendererType; +use crate::renderer::{RendererType, ScionRenderer}; + +use crate::renderer::bidimensional::triangle::Triangle; /// `Scion` is the entry point of any application made with Scion engine. pub struct Scion { @@ -14,7 +16,8 @@ pub struct Scion { world: World, resources: Resources, schedule: Schedule, - context: Option + context: Option, + renderer: Box, } impl EventHandlerFree for Scion { @@ -23,9 +26,11 @@ impl EventHandlerFree for Scion { } fn draw(&mut self) { - self.context.as_mut().expect("Miniquad context is mandatory to use the eventHandlerFree") - .clear(Some((0., 1., 1., 1.)), None, None); + self.renderer.draw( + self.context.as_mut().expect("Miniquad context is mandatory"), + &mut self.world, &mut self.resources) } + fn resize_event(&mut self, w: f32, h: f32) { self.resources .get_mut::().expect("Missing Screen Dimension Resource. Did something deleted it ?").set(w, h); @@ -51,18 +56,19 @@ impl Scion { ScionBuilder::new(app_config) } - fn setup(mut self, context: Context ) -> Self{ + fn setup(mut self, context: Context) -> Self { let screen_size = context.screen_size(); self.context = Some(context); self.resources.insert(Time::default()); self.resources.insert(WindowDimensions::new(screen_size)); + self.world.push((Triangle,)); self } fn next_frame(&mut self) { - self.resources.get_mut::