diff options
author | Adrian Kummerlaender | 2016-12-10 12:42:20 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2016-12-10 12:42:20 +0100 |
commit | f864f31f8ef206a363d0dac43558d42c5db46baa (patch) | |
tree | 36596e44a628654dc09513c9bbf66ef699afac9b /src | |
parent | 585e558afb23acc87d3ad71b2fef974281a185dd (diff) | |
download | termlife-f864f31f8ef206a363d0dac43558d42c5db46baa.tar termlife-f864f31f8ef206a363d0dac43558d42c5db46baa.tar.gz termlife-f864f31f8ef206a363d0dac43558d42c5db46baa.tar.bz2 termlife-f864f31f8ef206a363d0dac43558d42c5db46baa.tar.lz termlife-f864f31f8ef206a363d0dac43558d42c5db46baa.tar.xz termlife-f864f31f8ef206a363d0dac43558d42c5db46baa.tar.zst termlife-f864f31f8ef206a363d0dac43558d42c5db46baa.zip |
Enable offset world drawing; center in viewport
Diffstat (limited to 'src')
-rw-r--r-- | src/world.h | 14 |
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() { |