diff options
author | Adrian Kummerlaender | 2016-12-10 12:44:30 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2016-12-10 12:44:30 +0100 |
commit | 839e1335d9f58cd4b681163e14299efe1eec5eb1 (patch) | |
tree | ac1ce1d16d6120cc5708f3c9a170adb78ba166a9 | |
parent | f864f31f8ef206a363d0dac43558d42c5db46baa (diff) | |
download | termlife-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.cc | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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: |