123456789101112131415161718192021222324252627 |
- use crate::components::{Velocity, Position};
- use crate::game::MyGame;
- use specs::RunNow;
- struct Physics;
- impl <'a> specs::System<'a> for Physics {
- type SystemData = (
- specs::ReadStorage<'a, Velocity>,
- specs::WriteStorage<'a, Position>,
- );
- fn run(&mut self, (velocity, mut position): Self::SystemData) {
- use specs::Join;
- for (vel, pos) in (&velocity, &mut position).join() {
- pos.x += vel.dx;
- pos.y += vel.dy;
- }
- }
- }
- pub fn systems(game: &mut MyGame) {
- Physics.run_now(&game.world.res);
- }
|