|
@@ -13,7 +13,7 @@ use specs::RunNow;
|
|
|
/// in.
|
|
|
pub struct Draw<'t, Phase> {
|
|
|
pub ctx: &'t mut Context,
|
|
|
- pub sprites: &'t mut SpriteBatch,
|
|
|
+ //pub sprites: &'t mut SpriteBatch,
|
|
|
pub _phase: Phase,
|
|
|
}
|
|
|
|
|
@@ -22,9 +22,10 @@ impl<'a, 't, Phase : specs::Component> specs::System<'a> for Draw<'t, Phase> {
|
|
|
specs::ReadStorage<'a, Position>,
|
|
|
specs::ReadStorage<'a, Sprite>,
|
|
|
specs::ReadStorage<'a, Phase>,
|
|
|
+ specs::WriteExpect<'a, SpriteBatch>,
|
|
|
);
|
|
|
|
|
|
- fn run(&mut self, (positions, sprites, phase): Self::SystemData) {
|
|
|
+ fn run(&mut self, (positions, sprites, phase, mut batch): Self::SystemData) {
|
|
|
use specs::Join;
|
|
|
|
|
|
for (pos, spr, _) in (&positions, &sprites, &phase).join() {
|
|
@@ -34,13 +35,13 @@ impl<'a, 't, Phase : specs::Component> specs::System<'a> for Draw<'t, Phase> {
|
|
|
scale: ggez::nalgebra::Point2::new(consts::SCALE, consts::SCALE),
|
|
|
..Default::default()
|
|
|
};
|
|
|
- self.sprites.add(param);
|
|
|
+ batch.add(param);
|
|
|
graphics::draw(
|
|
|
self.ctx,
|
|
|
- self.sprites,
|
|
|
+ &*batch,
|
|
|
ggez::nalgebra::Point2::new(0.0, 0.0),
|
|
|
0.0).unwrap();
|
|
|
- self.sprites.clear();
|
|
|
+ batch.clear();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -52,27 +53,17 @@ pub fn systems(game: &mut MyGame, ctx: &mut Context) -> ggez::GameResult<()> {
|
|
|
|
|
|
Draw {
|
|
|
ctx,
|
|
|
- sprites: &mut game.sprites,
|
|
|
_phase: components::Background,
|
|
|
}.run_now(&game.world.res);
|
|
|
Draw {
|
|
|
ctx,
|
|
|
- sprites: &mut game.sprites,
|
|
|
_phase: components::Foreground,
|
|
|
}.run_now(&game.world.res);
|
|
|
Draw {
|
|
|
ctx,
|
|
|
- sprites: &mut game.sprites,
|
|
|
_phase: components::Decoration,
|
|
|
}.run_now(&game.world.res);
|
|
|
|
|
|
- graphics::draw(
|
|
|
- ctx,
|
|
|
- &game.sprites,
|
|
|
- ggez::nalgebra::Point2::new(0.0, 0.0),
|
|
|
- 0.0
|
|
|
- )?;
|
|
|
- game.sprites.clear();
|
|
|
graphics::present(ctx);
|
|
|
Ok(())
|
|
|
}
|