From 4417a34edb7d002276f0419a5f62c6eee4a3af87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 3 May 2020 02:15:11 +0200 Subject: [PATCH] Fix "1 cells" overlay in `game_of_life` --- examples/game_of_life/src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/game_of_life/src/main.rs b/examples/game_of_life/src/main.rs index 018ebc50..c2f80dfc 100644 --- a/examples/game_of_life/src/main.rs +++ b/examples/game_of_life/src/main.rs @@ -435,16 +435,19 @@ mod grid { if let Some(cell) = hovered_cell { frame.fill_text(Text { - content: format!("({}, {})", cell.i, cell.j), + content: format!("({}, {})", cell.j, cell.i), position: text.position - Vector::new(0.0, 16.0), ..text }); } + let cell_count = self.state.cell_count(); + frame.fill_text(Text { content: format!( - "{} cells @ {:?} ({})", - self.state.cell_count(), + "{} cell{} @ {:?} ({})", + cell_count, + if cell_count == 1 { "" } else { "s" }, self.last_tick_duration, self.last_queued_ticks ),