aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2016-12-11 18:49:20 +0100
committerAdrian Kummerlaender2016-12-11 18:49:20 +0100
commita653a3a2823e9bcecc80ec639cd5d2743f3edd04 (patch)
tree82754818f93d39187689669e13602ffe65ce1028
parent7082c43f116902173d332d81e97f98c306c0dcba (diff)
downloadtermlife-a653a3a2823e9bcecc80ec639cd5d2743f3edd04.tar
termlife-a653a3a2823e9bcecc80ec639cd5d2743f3edd04.tar.gz
termlife-a653a3a2823e9bcecc80ec639cd5d2743f3edd04.tar.bz2
termlife-a653a3a2823e9bcecc80ec639cd5d2743f3edd04.tar.lz
termlife-a653a3a2823e9bcecc80ec639cd5d2743f3edd04.tar.xz
termlife-a653a3a2823e9bcecc80ec639cd5d2743f3edd04.tar.zst
termlife-a653a3a2823e9bcecc80ec639cd5d2743f3edd04.zip
Only print non-null life densities
-rw-r--r--README.md2
-rw-r--r--life.cc6
2 files changed, 6 insertions, 2 deletions
diff --git a/README.md b/README.md
index 831d505..a8e3d8a 100644
--- a/README.md
+++ b/README.md
@@ -2,4 +2,4 @@
...is a straight forward toy implementation of Conway's Game of Life. It is written in C++ using `termbox` for drawing in the terminal. _Divine intervention_ i.e. manipulating the world state is supported using the mouse.
-[![asciicast](https://asciinema.org/a/b8ikx32sc5fe427b86y7kjgh7.png)](https://asciinema.org/a/b8ikx32sc5fe427b86y7kjgh7)
+[![asciicast](https://asciinema.org/a/f4nc8r6v1tf2m97s6m81ci37q.png)](https://asciinema.org/a/f4nc8r6v1tf2m97s6m81ci37q)
diff --git a/life.cc b/life.cc
index ad69d56..ee522ec 100644
--- a/life.cc
+++ b/life.cc
@@ -22,7 +22,11 @@ void draw(
if ( world.isLifeAt(i-x, j-y) ) {
tb_change_cell(i, j, 48+density, TB_BLACK, TB_GREEN);
} else {
- tb_change_cell(i, j, 48+density, TB_BLACK, TB_BLUE);
+ if ( density == 0 ) {
+ tb_change_cell(i, j, ' ', TB_BLACK, TB_BLUE);
+ } else {
+ tb_change_cell(i, j, 48+density, TB_BLACK, TB_BLUE);
+ }
}
});