survivor

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

commit
181a89fadcb85c21488c5f93e507abd50822beb0
parent
34ee53f4ebd22b2f40633f333929ee09e86589f8
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-02-18 22:47
limit total number of enemies

Diffstat

M src/main.rs 3 ++-

1 files changed, 2 insertions, 1 deletions


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

@@ -10,6 +10,7 @@ use std::{thread, time};
   10    10 use std::sync::atomic::{AtomicBool, Ordering};
   11    11 
   12    12 const TICK: time::Duration = time::Duration::from_millis(33);
   -1    13 const MAX_ENEMIES: usize = 100;
   13    14 
   14    15 const PERK_POWER: usize = 0;
   15    16 const PERK_HEALTH: usize = 1;
@@ -290,7 +291,7 @@ fn main() {
  290   291         }
  291   292 
  292   293         // spawn
  293    -1         if rng.gen_f32() < dt * 2.0 {
   -1   294         if enemies.len() < MAX_ENEMIES && rng.gen_f32() < dt * 2.0 {
  294   295             let (spawn_x, spawn_y) = match rng.gen_range(0, 4) {
  295   296                 0 => (
  296   297                     rng.gen_f32() * width,