survivor

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

commit
b8626079cb9148060b3745755dc27d49ab67e112
parent
d375fc4d2a3024273aa296ab6bd60e0a46673096
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-03-28 06:03
weapon amounts

Diffstat

M src/game.rs 22 ++++++++++++----------
M src/weapons.rs 7 +++++++

2 files changed, 19 insertions, 10 deletions


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

@@ -218,16 +218,18 @@ impl Game {
  218   218             weapon.last += dt;
  219   219             if weapon.last > weapon.cooldown {
  220   220                 weapon.last -= weapon.cooldown;
  221    -1                 weapon.projectiles.push(weapons::Projectile {
  222    -1                     p: Pos {
  223    -1                         x: self.player.p.x + self.rng.gen_f32() * 10.0 - 5.0,
  224    -1                         y: self.player.p.y + self.rng.gen_f32() * 10.0 - 5.0,
  225    -1                     },
  226    -1                     dir: match &self.player.dir {
  227    -1                         Some(dir) => dir.clone(),
  228    -1                         None => self.player.face,
  229    -1                     },
  230    -1                 });
   -1   221                 for _ in 0..weapon.amount {
   -1   222                     weapon.projectiles.push(weapons::Projectile {
   -1   223                         p: Pos {
   -1   224                             x: self.player.p.x + self.rng.gen_f32() * 10.0 - 5.0,
   -1   225                             y: self.player.p.y + self.rng.gen_f32() * 10.0 - 5.0,
   -1   226                         },
   -1   227                         dir: match &self.player.dir {
   -1   228                             Some(dir) => dir.clone(),
   -1   229                             None => self.player.face,
   -1   230                         },
   -1   231                     });
   -1   232                 }
  231   233             }
  232   234         }
  233   235     }

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

@@ -5,6 +5,7 @@ pub struct WeaponType {
    5     5     pub base_speed: f32,
    6     6     pub base_damage: f32,
    7     7     pub base_cooldown: f32,
   -1     8     pub base_amount: u8,
    8     9     pub size: f32,
    9    10     pub sprite: &'static sprites::Sprite,
   10    11     pub _move: fn(&mut Projectile, &Pos, speed: f32, dt: f32) -> (),
@@ -19,6 +20,7 @@ pub struct Weapon {
   19    20     pub speed: f32,
   20    21     pub damage: f32,
   21    22     pub cooldown: f32,
   -1    23     pub amount: u8,
   22    24     pub last: f32,
   23    25     pub t: &'static WeaponType,
   24    26     pub projectiles: Vec<Projectile>,
@@ -30,6 +32,7 @@ impl Weapon {
   30    32             speed: t.base_speed,
   31    33             damage: t.base_damage,
   32    34             cooldown: t.base_cooldown,
   -1    35             amount: t.base_amount,
   33    36             last: 0.0,
   34    37             t: t,
   35    38             projectiles: vec![],
@@ -90,6 +93,7 @@ pub const AXE: WeaponType = WeaponType {
   90    93     base_speed: 150.0,
   91    94     base_damage: 50.0,
   92    95     base_cooldown: 10.0,
   -1    96     base_amount: 2,
   93    97     size: 7.0,
   94    98     sprite: &sprites::AXE,
   95    99     _move: move_parabola,
@@ -99,6 +103,7 @@ pub const KNIFE: WeaponType = WeaponType {
   99   103     base_speed: 200.0,
  100   104     base_damage: 30.0,
  101   105     base_cooldown: 4.0,
   -1   106     base_amount: 1,
  102   107     size: 6.0,
  103   108     sprite: &sprites::KNIFE,
  104   109     _move: move_straight,
@@ -108,6 +113,7 @@ pub const STAR: WeaponType = WeaponType {
  108   113     base_speed: 250.0,
  109   114     base_damage: 20.0,
  110   115     base_cooldown: 3.0,
   -1   116     base_amount: 3,
  111   117     size: 6.0,
  112   118     sprite: &sprites::STAR,
  113   119     _move: move_diagonal,
@@ -117,6 +123,7 @@ pub const WIND: WeaponType = WeaponType {
  117   123     base_speed: 100.0,
  118   124     base_damage: 40.0,
  119   125     base_cooldown: 9.0,
   -1   126     base_amount: 1,
  120   127     size: 8.0,
  121   128     sprite: &sprites::WIND,
  122   129     _move: move_spiral,