diff --git a/src/tetris.c b/src/tetris.c index 79e72e7..f826798 100644 --- a/src/tetris.c +++ b/src/tetris.c @@ -62,7 +62,11 @@ int tetris_intersect(const u8 *restrict const *restrict rows, u8 tetromino, uint uint *pos = (uint[8]){x, y, x, y, x, y, x, y}; uint *end = pos + 8; tetris_get_blocks(tetromino, pos); - while (pos < end && !rows[*(pos + 1)][*pos]) pos += 2; + for (; pos < end; pos += 2) { + if (*(pos + 0) >= TET_WIDTH) break; + if (*(pos + 1) >= TET_HEIGHT) break; + if (rows[*(pos + 1)][*pos]) break; + } return pos < end; }