Skip to content

Commit f663dc5

Browse files
Add evildoers count
1 parent 6865c2a commit f663dc5

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
[package]
22
name = "call_of_ferris"
33
version = "0.1.0"
4-
authors = ["user <[email protected]>"]
4+
authors = ["Anhad Singh <[email protected]>"]
5+
description = """
6+
A thrilling action game where your favorite Ferris the crab and the rust mascot got guns and has taken up the duty to find evildoer languages while managing to keep itself alive.
7+
Take part in this awesome adventure and help Ferris be the best ever!
8+
"""
9+
repository = "https://github.com/Andy-Python-Programmer/CallOfFerris"
510
edition = "2018"
611

7-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8-
912
[dependencies]
1013
ggez = "0.5"
1114
rand = "0.7"

src/game.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ pub struct Game {
7373

7474
draw_end_text: (bool, Option<usize>, bool, bool), // Thread Sleeped?, Current Iters, Done?, Win?
7575
can_die: bool,
76+
total_enemies: i32
7677
}
7778

7879
impl Game {
@@ -181,9 +182,9 @@ impl Game {
181182
dim_shader,
182183
dim_constant,
183184
draw_end_text: (false, None, false, false),
184-
185185
end: map_1.end,
186186
can_die: true,
187+
total_enemies: map_1.total_enemies
187188
})
188189
}
189190

@@ -446,6 +447,17 @@ impl Game {
446447
.scale(Vector2 { x: 0.7, y: 0.7 }),
447448
)?;
448449

450+
let evildoers = &Text::new(
451+
TextFragment::new(format!("Evildoers {}/{}", self.enemies.len(), self.total_enemies))
452+
.font(self.consolas)
453+
.scale(Scale::uniform(20.)),
454+
);
455+
456+
let evildoers_dim = evildoers.dimensions(ctx);
457+
458+
graphics::draw(ctx, evildoers, DrawParam::default()
459+
.dest(Point2::new((WIDTH - evildoers_dim.0 as f32) - 40., 20.)))?;
460+
449461
Ok(())
450462
}
451463

src/map.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub struct Map {
1111

1212
pub ground: Vec<Tile>,
1313
pub enemies: Vec<Enemy>,
14+
pub total_enemies: i32,
1415
pub barrels: Vec<Barrel>,
1516

1617
pub player: Option<Player>,
@@ -25,6 +26,7 @@ impl Map {
2526

2627
ground: vec![],
2728
enemies: vec![],
29+
total_enemies: 0,
2830
barrels: vec![],
2931

3032
player: None,
@@ -68,6 +70,7 @@ impl Map {
6870
self.enemies.push(Enemy::new(self.draw_pos));
6971

7072
self.draw_pos += self.draw_inc;
73+
self.total_enemies += 1;
7174
}
7275

7376
'4' => {

0 commit comments

Comments
 (0)