survivor

graphical action game for the linux terminal
git clone https://git.ce9e.org/survivor.git

commit
8e27f4c6ccee7b0dd09b84fa5a2e26367e19bc6e
parent
51d2a2a36707c386026f473ce5ae6b1c2b8d38c0
Author
Viktor Bahr <viktorbahr@posteo.net>
Date
2023-03-26 17:02
feat: move projectiles

Diffstat

M src/game.rs 12 ++++++++++++

1 files changed, 12 insertions, 0 deletions


diff --git a/src/game.rs b/src/game.rs

@@ -165,6 +165,17 @@ impl Game {
  165   165         }
  166   166     }
  167   167 
   -1   168     fn move_projectiles(&mut self, dt: f32) {
   -1   169         for projectile in self.projectiles.iter_mut() {
   -1   170             match projectile.dir {
   -1   171                 Dir::Up => projectile.p.y -= projectile.t.speed * dt,
   -1   172                 Dir::Right => projectile.p.x += projectile.t.speed * dt,
   -1   173                 Dir::Down => projectile.p.y += projectile.t.speed * dt,
   -1   174                 Dir::Left => projectile.p.x -= projectile.t.speed * dt,
   -1   175             }
   -1   176         }
   -1   177     }
   -1   178 
  168   179     fn spawn_enemies(&mut self, dt: f32, width: f32, height: f32) {
  169   180         let sprite_height = win::iconvert_y(sprites::HEIGHT);
  170   181         let sprite_width = win::iconvert_x(sprites::WIDTH);
@@ -286,6 +297,7 @@ impl Game {
  286   297     pub fn step(&mut self, dt: f32, width: f32, height: f32) {
  287   298         self.move_player(dt);
  288   299         self.move_enemies(dt);
   -1   300         self.move_projectiles(dt);
  289   301         self.despawn_enemies(width, height);
  290   302         self.despawn_projectiles(width, height);
  291   303