diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 60186b3..8bc4faf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,16 @@ +#![allow(dead_code)] + pub mod components; +pub mod math; pub mod systems; pub mod texture_manager; -use components::{Pos, StaticDrawable}; +use components::*; +use math::Vec2; +use sdl2::rect::Rect; use specs::prelude::*; use specs::{DispatcherBuilder, World}; -use systems::{SysDraw, SysInput}; +use systems::{SysDraw, SysInput, SysMovement}; fn main() { @@ -23,23 +28,30 @@ fn main() let mut world = World::new(); world.register::<Pos>(); world.register::<StaticDrawable>(); + world.register::<Velocity>(); + world.register::<Player>(); world .create_entity() - .with(Pos { x: 0., y: 0. }) + .with(Pos(Vec2::new(0., 0.))) + .with(Velocity(Vec2::new(0., 0.))) .with(StaticDrawable { texture_name: "portraits.png".to_string(), + source_rect: Rect::new(0, 0, 40, 40), }) + .with(Player) .build(); let sys_input = SysInput::new(&sdl); let sys_draw = SysDraw::new(window); + let sys_move = SysMovement::new(); let mut dispatcher = DispatcherBuilder::new() + .with(sys_move, "move", &[]) .with_thread_local(sys_input) .with_thread_local(sys_draw) .build(); loop { - dispatcher.dispatch(&mut world); + dispatcher.dispatch(&world); } } |
