~sircmpwn/tetrominoes

307d926bea3fe5e7635288bdb70e47681b486a8b — Drew DeVault 5 months ago cb6325f
Allow the player to rotate in two directions
1 files changed, 7 insertions(+), 7 deletions(-)

M update.ha
M update.ha => update.ha +7 -7
@@ 40,9 40,10 @@ fn update(state: *state) (void | sdl2::error) = {
			move_left(state);
		case controller_button::DPAD_RIGHT =>
			move_right(state);
		case controller_button::A, controller_button::B,
				controller_button::X, controller_button::Y =>
			rotate(state);
		case controller_button::A =>
			rotate(state, 1);
		case controller_button::B =>
			rotate(state, -1);
		case controller_button::DPAD_UP =>
			if (state.state != gamestate::INTRO) {
				state.board.active_y = state.board.ghost_y;


@@ 176,10 177,9 @@ fn move_right(state: *state) void = {
	};
};

fn rotate(state: *state) void = {
fn rotate(state: *state, d: int) void = {
	const board = &state.board;
	const next = board.active_i + 1;
	const next = next % len(board.active): int;
	const next = (board.active_i + d): size % len(board.active);
	const active = &state.board.active[next];

	let i = 0z;


@@ 190,6 190,6 @@ fn rotate(state: *state) void = {
	};

	board.active_x += mods[i];
	board.active_i = next;
	board.active_i = next: int;
	update_ghost(state);
};