diff options
author | Oxore <oxore@protonmail.com> | 2017-12-09 11:45:51 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2017-12-09 11:45:51 +0300 |
commit | 6ee4bf59b927c31cf9ba7b340d1b03d598b2a527 (patch) | |
tree | 90ff3da9d1d9041385642e97cdc2218e8265e624 | |
parent | 0f23a894e51fe11cecb6fd762a6360224717912c (diff) |
Level up condition removed lines count
-rw-r--r-- | include/common.h | 1 | ||||
-rw-r--r-- | include/functions.h | 2 | ||||
-rw-r--r-- | include/tet_conf.h | 2 | ||||
-rw-r--r-- | src/functions.c | 11 | ||||
-rw-r--r-- | src/main.c | 2 |
5 files changed, 12 insertions, 6 deletions
diff --git a/include/common.h b/include/common.h index 49c15d3..9e1a847 100644 --- a/include/common.h +++ b/include/common.h @@ -50,6 +50,7 @@ typedef struct Game { int isStarted; int scoreCurrent; int level; + int lines; } Game; /* ======== text.[c|h] types =========== */ diff --git a/include/functions.h b/include/functions.h index 0e6e26a..b307a31 100644 --- a/include/functions.h +++ b/include/functions.h @@ -20,7 +20,7 @@ int wallRotCollisionCheck(); void rotateLeft(); void rotateRight(); void rotateShape(); -int linesRmScore(); +int rmLines(); void valueAfterTextDisplay(int value, List *texts, char *type); void colorizeFld(); void colorizeActive(); diff --git a/include/tet_conf.h b/include/tet_conf.h index 4bf0236..55a4011 100644 --- a/include/tet_conf.h +++ b/include/tet_conf.h @@ -16,7 +16,7 @@ #define basicLatency 500000 #define PUT_LATENCY 300000 #define RM_LINE_SCORE 100 -#define LEVELUP_SCORE 100 +#define LEVELUP_LINES 10 /* diff --git a/src/functions.c b/src/functions.c index 2ea72ea..ab887b4 100644 --- a/src/functions.c +++ b/src/functions.c @@ -99,7 +99,7 @@ void valueAfterTextDisplay(int value, List *texts, char *type) * Removes line when cells all are in row in it * */ -int linesRmScore() +int rmLines() { int k = 0; // "Filled line" indicator int s = 0; @@ -148,7 +148,9 @@ void putShape() if ((j+active.y >= 0) && (i+active.x >= 0)) fld.c[j+active.y][i+active.x].fColor = active.fColor; } - game.scoreCurrent += linesRmScore()*RM_LINE_SCORE; // Remove filled lines and get score; + int removedLines = rmLines(); + game.lines += removedLines; + game.scoreCurrent += removedLines*RM_LINE_SCORE; resetActiveShape(&active); checkLevelUp(&game); } @@ -169,8 +171,10 @@ int outOfFieldCheck(Field *fld, Shape *active) void checkLevelUp(Game *game) { if (game->level < 15) - if (game->scoreCurrent >= game->level * LEVELUP_SCORE) + while (game->lines >= LEVELUP_LINES) { game->level++; + game->lines -= LEVELUP_LINES; + } } void resetActiveShape(Shape *active) @@ -554,6 +558,7 @@ void gameover(Game *game) game->isStarted = 0; game->scoreCurrent = 0; game->level = 1; + game->lines = 0; } @@ -13,7 +13,7 @@ #include "tet_conf.h" Window w = {.mode = {450, 570, 32}}; -Game game = {.isStarted = 0, .scoreCurrent = 0, .level = 1}; +Game game = {.isStarted = 0, .scoreCurrent = 0, .level = 1, .lines = 0}; List *texts; sfFont *fontScore; Shape active, next; |