From f864f31f8ef206a363d0dac43558d42c5db46baa Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 10 Dec 2016 12:42:20 +0100 Subject: Enable offset world drawing; center in viewport --- src/world.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/world.h') diff --git a/src/world.h b/src/world.h index d951cf5..72cc32f 100644 --- a/src/world.h +++ b/src/world.h @@ -69,11 +69,21 @@ class World { } void summonLifeAt(std::size_t x, std::size_t y) { - this->matrix_[y][x] = true; + if ( x >= 0 && + x < WIDTH && + y >= 0 && + y < HEIGHT ) { + this->matrix_[y][x] = true; + } } void extinguishLifeAt(std::size_t x, std::size_t y) { - this->matrix_[y][x] = false; + if ( x >= 0 && + x < WIDTH && + y >= 0 && + y < HEIGHT ) { + this->matrix_[y][x] = false; + } } void tick() { -- cgit v1.2.3