Skip to content

Commit

Permalink
fixes: guards drawing
Browse files Browse the repository at this point in the history
changed defaults
  • Loading branch information
lewis-weinberger committed Feb 13, 2023
1 parent b658593 commit b092cb3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use std::fmt;
use std::time::Duration;

// View-cone parameters
const LENGTH: i16 = 10;
const WIDTH: usize = 8;
const LENGTH: i16 = 16;
const WIDTH: usize = 10;

#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)]
pub enum Status {
Expand Down
26 changes: 14 additions & 12 deletions src/ui/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::time::{Duration, Instant};

const TIMEOUT: u64 = 300;
const ATTACKER_ACTIONS: isize = 5;
const DEFENDER_ACTIONS: isize = 8;
const DEFENDER_ACTIONS: isize = 12;

pub struct Terminal {
stdout: Stdout,
Expand Down Expand Up @@ -153,19 +153,21 @@ impl UserInterface for Terminal {
}
}

for (i, guard) in game.guards.iter().enumerate() {
if let Some((pos, _dir)) = guard {
// View cones
for (pos, tile) in game.view_cone(i).iter() {
if let Some((x, y)) = self.map_to_display(*pos) {
queue!(
self.stdout,
MoveTo(x, y),
PrintStyledContent(tile.to_string().on_red())
)?;
}
for i in 0..game.guards.len() {
// View cones
for (pos, tile) in game.view_cone(i).iter() {
if let Some((x, y)) = self.map_to_display(*pos) {
queue!(
self.stdout,
MoveTo(x, y),
PrintStyledContent(tile.to_string().on_red())
)?;
}
}
}

for (i, guard) in game.guards.iter().enumerate() {
if let Some((pos, _dir)) = guard {
// Display guards
if let Some((x, y)) = self.map_to_display(*pos) {
let g = if defender && i == self.guard {
Expand Down

0 comments on commit b092cb3

Please sign in to comment.