diff options
author | Guillaume Pasquet <dev@etenil.net> | 2020-01-02 17:28:15 +0000 |
---|---|---|
committer | Guillaume Pasquet <dev@etenil.net> | 2020-03-14 16:52:06 +0000 |
commit | 219e32ad793e66a3111465ef02f3eb677f70277d (patch) | |
tree | ffbfc495906fdb447074c1c1e3e4996432f83a14 /src/world.rs | |
parent | 9848a92fde2891177cc352064ae9e4ec1098277f (diff) |
Fix for invisible enemies
- Don't double-count visibility
- Set enemies visibility with LOS
- Set dirty flag when enemies are revealed
Diffstat (limited to 'src/world.rs')
-rw-r--r-- | src/world.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/world.rs b/src/world.rs index af72513..c577680 100644 --- a/src/world.rs +++ b/src/world.rs @@ -430,16 +430,17 @@ impl Generatable for Level { let room = &self.rooms[rng.gen_range(0, self.rooms.len() - 1)]; // Create the enemy + let enemy_coords = ( + room.start.0 + rng.gen_range(0, room.width - 1) + 1, + room.start.1 + rng.gen_range(0, room.height - 1) + 1, + ); self.entities.push(Box::<Character>::new(Enemy::new( String::from("snake"), 2 * self.depth as i32, (2.0 * self.depth as f32 * 0.6).round() as i32, (20.0 * self.depth as f32 * 0.2).max(80.0).round() as i32, 0, - ( - room.start.0 + rng.gen_range(0, room.width), - room.start.1 + rng.gen_range(0, room.height), - ), + enemy_coords, "s", ))); } |