aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/world.h14
1 files changed, 12 insertions, 2 deletions
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() {