survivor

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

commit
ad4b2f7a700a916431e6bdb0beb268327da5f08d
parent
555ffa987e25f7fa44582119f7778a9da1563bef
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-03-30 09:01
create constant for SPAWN_RADIUS

Diffstat

M src/game.rs 4 ++--
M src/weapons.rs 2 ++

2 files changed, 4 insertions, 2 deletions


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

@@ -226,8 +226,8 @@ impl Game {
  226   226                 for _ in 0..weapon.amount {
  227   227                     weapon.projectiles.push(weapons::Projectile {
  228   228                         p: Pos {
  229    -1                             x: self.player.p.x + self.rng.gen_f32() * 10.0 - 5.0,
  230    -1                             y: self.player.p.y + self.rng.gen_f32() * 10.0 - 5.0,
   -1   229                             x: self.player.p.x + (self.rng.gen_f32() - 0.5) * weapons::SPAWN_RADIUS,
   -1   230                             y: self.player.p.y + (self.rng.gen_f32() - 0.5) * weapons::SPAWN_RADIUS,
  231   231                         },
  232   232                         dir: match &self.player.dir {
  233   233                             Some(dir) => dir.clone(),

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

@@ -1,6 +1,8 @@
    1     1 use crate::game::{Dir, Pos};
    2     2 use crate::sprites;
    3     3 
   -1     4 pub const SPAWN_RADIUS: f32 = 10.0;
   -1     5 
    4     6 pub struct Projectile {
    5     7     pub p: Pos,
    6     8     pub dir: Dir,