Sort ECS stuff into modules

This commit is contained in:
Alex Page 2022-01-26 00:54:14 -05:00
parent 5ba82fd26c
commit 8bdc8e31d6
9 changed files with 75 additions and 46 deletions

View file

@ -0,0 +1,17 @@
use crate::components::{left_mover::LeftMover, position::Position};
use specs::prelude::*;
pub struct LeftWalker {}
impl<'a> System<'a> for LeftWalker {
type SystemData = (ReadStorage<'a, LeftMover>, WriteStorage<'a, Position>);
fn run(&mut self, (lefty, mut pos): Self::SystemData) {
for (_lefty, pos) in (&lefty, &mut pos).join() {
pos.x -= 1;
if pos.x < 0 {
pos.x = 65;
}
}
}
}

3
src/systems/mod.rs Normal file
View file

@ -0,0 +1,3 @@
pub use left_walker::LeftWalker;
pub mod left_walker;