From 6ee4bf59b927c31cf9ba7b340d1b03d598b2a527 Mon Sep 17 00:00:00 2001 From: Oxore Date: Sat, 9 Dec 2017 11:45:51 +0300 Subject: Level up condition removed lines count --- src/functions.c | 11 ++++++++--- src/main.c | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src') 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; } diff --git a/src/main.c b/src/main.c index 5b4b931..af6f6ba 100644 --- a/src/main.c +++ b/src/main.c @@ -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; -- cgit v1.2.3