mirror of
https://github.com/thepigeongenerator/tetris_clone.git
synced 2025-12-17 05:55:46 +01:00
differentiate between out-of-bounds intersection and regular intersection.
This commit is contained in:
@@ -63,8 +63,8 @@ int tetris_intersect(const u8 *restrict const *restrict rows, u8 tetromino, uint
|
||||
uint *end = pos + 8;
|
||||
tetris_get_blocks(tetromino, pos);
|
||||
for (; pos < end; pos += 2) {
|
||||
if (*(pos + 0) >= TET_WIDTH) break;
|
||||
if (*(pos + 1) >= TET_HEIGHT) break;
|
||||
if (*(pos + 0) >= TET_WIDTH) return 2;
|
||||
if (*(pos + 1) >= TET_HEIGHT) return 2;
|
||||
if (rows[*(pos + 1)][*pos]) break;
|
||||
}
|
||||
return pos < end;
|
||||
|
||||
@@ -50,7 +50,8 @@ void tetris_init_rows(const u8 *restrict data, const u8 *restrict *restrict out)
|
||||
* Returns the amount of rows cleared. */
|
||||
int tetris_clear_rows(u8 *restrict *restrict rows) NONNULL((1));
|
||||
|
||||
/* Checks if `tetromino` intersects at (`x`, `y`) in `rows`, returns `1` if so, `0` if not. */
|
||||
/* Checks if `tetromino` intersects at (`x`, `y`) in the data within `rows` or is out-of-bounds,
|
||||
* returns `1` if it overlaps within `rows`, `2` if it is out-of-bounds, `0` if no intersection is found. */
|
||||
int tetris_intersect(const u8 *restrict const *restrict rows, u8 tetromino, uint x, uint y) NONNULL((1));
|
||||
|
||||
/* Writes the blocks of `tetromino` to `rows` at position `x` and `y`. */
|
||||
|
||||
Reference in New Issue
Block a user