From 839e1335d9f58cd4b681163e14299efe1eec5eb1 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 10 Dec 2016 12:44:30 +0100 Subject: Enable manually extinguishing life --- life.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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: -- cgit v1.2.3