M board.ha => board.ha +1 -1
@@ 112,7 112,7 @@ fn canmove(
if (active[active_ix] == 0) {
continue;
};
- if (x + active_x < 0 || x + active_x >= BOARD_WIDTH) {
+ if (x + dx + active_x < 0 || x + dx + active_x >= BOARD_WIDTH) {
return false;
};
if (y + dy + active_y < 0) {
M notes.txt => notes.txt +0 -2
@@ 1,7 1,5 @@
-- instant place
- fix thumbsticks
- scorekeeping/display
-- try to accomodate rotation by moving pieces left/right
- piece swapping
- keyboard input
- victory (+animation)
M update.ha => update.ha +7 -2
@@ 159,14 159,19 @@ fn move_right(state: *state) void = {
};
fn rotate(state: *state) void = {
- // TODO: Make sure this rotation is allowed
const board = &state.board;
const next = board.active_i + 1;
const next = next % len(board.active): int;
const active = &state.board.active[next];
- if (!canmove(state, active, 0, 0)) {
+
+ let i = 0z;
+ const mods = [0, -1, 1];
+ for (i < len(mods) && !canmove(state, active, mods[i], 0); i += 1) void;
+ if (i >= len(mods)) {
return;
};
+
+ board.active_x += mods[i];
board.active_i = next;
update_ghost(state);
};