Skip to content

Commit

Permalink
Merge branch 'improve_scoring_system'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkun committed Sep 13, 2020
2 parents 194f919 + f0404a1 commit 4fa4163
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ Supported Platforms

**AWKTC** has been tested in the following platforms:

* Debian GNU/Linux 9
* FreeBSD 11.1-RELEASE
* Debian GNU/Linux 10
* FreeBSD 12.1-RELEASE

How to Play
-----------

### Running the Game ###

``` shellsession
```console
$ cd /path/to/AWKTC
$ ./awktc.awk
```
Expand Down Expand Up @@ -59,15 +59,15 @@ You can change the playfield width between 4 and 24 cells. By default, the playf

### Example Minimum Width ###

``` shellsession
```console
$ ./awktc.awk 4
```

![Screenshot (width: 4)](./md-images/screenshot-width04.png)

### Example Maximum Width ###

``` shellsession
```console
$ ./awktc.awk 24
```

Expand All @@ -76,7 +76,7 @@ $ ./awktc.awk 24
Installation
------------

``` shellsession
```console
$ git clone https://github.com/mikkun/AWKTC.git
```

Expand All @@ -88,4 +88,4 @@ Author
License
-------

[MIT](./LICENSE)
[MIT License](./LICENSE)
14 changes: 5 additions & 9 deletions awktc.awk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Purpose : AWKTC is Workable Klutzy Time-wasting Command
#
# Author : KUSANAGI Mitsuhisa <[email protected]>
# Licence : MIT license
# License : MIT License

# Usage : ./awktc.awk [width]

Expand All @@ -20,7 +20,7 @@ BEGIN {
MAX_LEVEL = 99;
MAX_LINES = 999999;
MAX_SCORE = 999999;
SCORE_UNIT = 100;
SCORE_UNIT = 10;

DELAY_SEC = 0.1;
READING_KEY_CMD = "((while :; do echo ''; sleep " DELAY_SEC "; done) &" \
Expand Down Expand Up @@ -266,7 +266,7 @@ function _is_all_clear( x) {
return 1;
}

function update_field( deleted_lines, is_line_created, i, x, y) {
function update_field( deleted_lines, is_line_created, points, i, x, y) {
deleted_lines = 0;
for (i = 0; i < PIECE_H; i++) {
for (y = field_h - BORDER_H; y > PIECE_H; y--) {
Expand All @@ -285,16 +285,12 @@ function update_field( deleted_lines, is_line_created, i, x, y) {
}
}
if (deleted_lines > 0) {
points = input_w * deleted_lines ^ 2 * SCORE_UNIT * level;
curr_level_exp += deleted_lines * 2 \
+ int(deleted_lines / PIECE_H) \
- 1;
lines += deleted_lines;
score += (deleted_lines * 2 \
+ int(deleted_lines / PIECE_H) \
- 1) * SCORE_UNIT * level;
if (_is_all_clear()) {
score += SCORE_UNIT * 10 * (field_w - BORDER_W);
}
score += _is_all_clear() ? points * 10 : points;
if (curr_level_exp >= next_level_exp) {
level_up();
}
Expand Down

0 comments on commit 4fa4163

Please sign in to comment.