optimise Y axis updating

This commit is contained in:
2025-06-26 12:00:55 +02:00
parent f41f5d3a6e
commit 402ef330de

View File

@@ -95,24 +95,17 @@ void place_update(struct gamedata* gdat, int movdat) {
u8 idx = gdat->pdat.idx; u8 idx = gdat->pdat.idx;
u8 id = gdat->pdat.nxt[idx]; u8 id = gdat->pdat.nxt[idx];
// set the shape if we moved vertically and intersected // update Y axis
if (movdat & MOVD) { tmp = !!(movdat & MOVD);
i8 y = gdat->pdat.sel[VY] + 1; gdat->pdat.sel[VY] += tmp;
if (shape_intersects(gdat->rows, id, gdat->pdat.sel)) { tmp = tmp && shape_intersects(gdat->rows, id, gdat->pdat.sel);
set_shape(gdat->rows + gdat->pdat.sel[VY], id, gdat->pdat.sel[VX]); // if the shape intersects vertically, write the shape at the current position and return if (tmp) {
gdat->pdat.sel[VY]--;
set_shape(gdat->rows + gdat->pdat.sel[VY], id, gdat->pdat.sel[VX]);
clear_rows(gdat->rows, &gdat->pnts); // clear the rows that have been completed clear_rows(gdat->rows, &gdat->pnts); // clear the rows that have been completed
// TODO: play place_sfx
next_shape(); next_shape();
if (shape_intersects(gdat->rows, gdat->pdat.idx, gdat->pdat.sel)) { // TODO: play place_sfx
window_close(); // return;
return;
}
// otherwise, just set Y
gdat->pdat.sel[VY] = y;
}
} }
// update X axis // update X axis