summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/functions.c11
-rw-r--r--src/main.c2
2 files changed, 9 insertions, 4 deletions
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;