Skip to content

Commit

Permalink
Merge branch 'implement_all_clear_bonus'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkun committed Mar 24, 2018
2 parents 5291091 + 8e55e7f commit 353bd72
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ $ ./awktc.awk

* ![Black piece](./md-images/special_piece.png) - __Special Piece__ - Destroys horizontal lines even if they have gaps of blocks.

### All Clear Bonus ###

If you clear all the pieces, then you will get an "All Clear Bonus".

Changing the Playfield Width
----------------------------

You can change the playfield width between 4 and 24 cells.

By default, the playfield width is 12 cells.
You can change the playfield width between 4 and 24 cells. By default, the playfield width is 12 cells.

### Example Minimum Width ###

Expand Down
15 changes: 14 additions & 1 deletion awktc.awk
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ BEGIN {
MAX_LEVEL = 99;
MAX_LINES = 999999;
MAX_SCORE = 999999;
SCORE_UNIT = 100;

DELAY_SEC = 0.1;
READING_KEY_CMD = "((while :; do echo ''; sleep " DELAY_SEC "; done) &" \
Expand Down Expand Up @@ -253,6 +254,15 @@ function _delete_line(target_y, x, y) {
}
}

function _is_all_clear( x) {
for (x = 1; x < field_w - 1; x++) {
if (field_data[x, field_h - 2] != 0) {
return 0;
}
}
return 1;
}

function update_field( deleted_lines, is_line_created, i, x, y) {
deleted_lines = 0;
for (i = 0; i < PIECE_H; i++) {
Expand All @@ -278,7 +288,10 @@ function update_field( deleted_lines, is_line_created, i, x, y) {
lines += deleted_lines;
score += (deleted_lines * 2 \
+ int(deleted_lines / PIECE_H) \
- 1) * 100 * level;
- 1) * SCORE_UNIT * level;
if (_is_all_clear()) {
score += SCORE_UNIT * 10 * (field_w - BORDER_W);
}
if (curr_level_exp >= next_level_exp) {
level_up();
}
Expand Down

0 comments on commit 353bd72

Please sign in to comment.