Sort ECS stuff into modules
This commit is contained in:
parent
5ba82fd26c
commit
8bdc8e31d6
9 changed files with 75 additions and 46 deletions
17
src/systems/left_walker.rs
Normal file
17
src/systems/left_walker.rs
Normal 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
3
src/systems/mod.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub use left_walker::LeftWalker;
|
||||
|
||||
pub mod left_walker;
|
Loading…
Add table
Add a link
Reference in a new issue