Skip to content

Commit

Permalink
Merge branch '#3_change_if_chain_to_if-else'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkun committed Nov 26, 2022
2 parents c46d901 + dd2aab2 commit 43c95d1
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions awktc.awk
Original file line number Diff line number Diff line change
Expand Up @@ -116,43 +116,40 @@ BEGIN {
READING_KEY_CMD | getline key

if (is_paused) {
if (key == "q") { exit 0 }
if (key == "p") { is_paused = 0 }
if (key == "q") { exit 0 }
else if (key == "p") { is_paused = 0 }
continue
}
if (key == "q") { exit 0 }
if (key == "p") {
else if (key == "q") { exit 0 }
else if (key == "p") {
is_paused = 1
print_message(" PAUSED ", 9)
continue
}

if (key == "a") {
else if (key == "a") {
curr_piece_x -= 1
if (has_collision()) { curr_piece_x += 1 }
}
if (key == "d") {
else if (key == "d") {
curr_piece_x += 1
if (has_collision()) { curr_piece_x -= 1 }
}
if (key == "s") {
else if (key == "s") {
curr_piece_y += 1
score += 1
if (has_collision()) {
curr_piece_y -= 1
score -= 1
}
}

if (key == "k") {
else if (key == "k") {
rotate_left()
if (has_collision()) { rotate_right() }
}
if (key == "l") {
else if (key == "l") {
rotate_right()
if (has_collision()) { rotate_left() }
}

if (key == "" && skip_count >= skip_limit) {
curr_piece_y += 1
if (has_collision()) {
Expand Down

0 comments on commit 43c95d1

Please sign in to comment.