aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2016-12-10 12:44:30 +0100
committerAdrian Kummerlaender2016-12-10 12:44:30 +0100
commit839e1335d9f58cd4b681163e14299efe1eec5eb1 (patch)
treeac1ce1d16d6120cc5708f3c9a170adb78ba166a9
parentf864f31f8ef206a363d0dac43558d42c5db46baa (diff)
downloadtermlife-839e1335d9f58cd4b681163e14299efe1eec5eb1.tar
termlife-839e1335d9f58cd4b681163e14299efe1eec5eb1.tar.gz
termlife-839e1335d9f58cd4b681163e14299efe1eec5eb1.tar.bz2
termlife-839e1335d9f58cd4b681163e14299efe1eec5eb1.tar.lz
termlife-839e1335d9f58cd4b681163e14299efe1eec5eb1.tar.xz
termlife-839e1335d9f58cd4b681163e14299efe1eec5eb1.tar.zst
termlife-839e1335d9f58cd4b681163e14299efe1eec5eb1.zip
Enable manually extinguishing life
-rw-r--r--life.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/life.cc b/life.cc
index d76055b..bbf49d0 100644
--- a/life.cc
+++ b/life.cc
@@ -77,7 +77,14 @@ int main(int, char*[]) {
break;
case TB_EVENT_MOUSE:
if ( ev.key == TB_KEY_MOUSE_LEFT ) {
- world.summonLifeAt(ev.x - worldOffsetX, ev.y - worldOffsetY);
+ const std::size_t x = ev.x - worldOffsetX;
+ const std::size_t y = ev.y - worldOffsetY;
+
+ if ( world.isLifeAt(x, y) ) {
+ world.extinguishLifeAt(x, y);
+ } else {
+ world.summonLifeAt(x, y);
+ }
}
break;
case TB_EVENT_RESIZE: