summaryrefslogtreecommitdiff
path: root/src/engine.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine.c')
-rw-r--r--src/engine.c92
1 files changed, 2 insertions, 90 deletions
diff --git a/src/engine.c b/src/engine.c
index 6df3c79..b5e1bac 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -28,10 +28,6 @@ extern sfClock *repPushDown; // Clock for repeat latency when Down key held
extern sfClock *repKeyLeft; // Clock for repeat latency when Left key held
extern sfClock *repKeyRight; // Clock for repeat latency when Left key held
-
-
-
-
void valueAfterTextDisplay(int value, List *texts, char *type)
{
List *l = texts;
@@ -54,41 +50,6 @@ void valueAfterTextDisplay(int value, List *texts, char *type)
}
}
-/*
- * Removes line when cells all are in row in it
- *
- */
-int rmLines()
-{
- int k = 0; // "Filled line" indicator
- int s = 0;
- for (int j = 0; j < 22; j++) {
- for (int i = 0; i < 10; i++)
- if (fld.c[j][i].a != 0)
- k++;
- if (k >= 10) { // If line is full
- s++; // Give scores for line
- for (int n = j; n < 22; n++) { // Drop all lines down
- if (n == 21) {
- for (int m = 0; m < 10; m++) {
- fld.c[n][m].a = 0;
- fld.c[n][m].fColor = UIBGCOLOR;
- }
- break;
- }
- for (int m = 0; m < 10; m++) {
- fld.c[n][m].a = fld.c[n+1][m].a;
- fld.c[n][m].fColor = fld.c[n+1][m].fColor;
- }
- }
- j--; // Do not let loop to go to next line because
- // next line go down by itself =)
- }
- k = 0; // Clear line fill indicator
- }
- return s; // Return number of deleted lines
-}
-
void checkLevelUp(struct game *game)
{
while (game->lines >= LEVELUP_LINES) {
@@ -153,7 +114,7 @@ void tTick()
return;
} else {
putShape(&fld, &active);
- int removedLines = rmLines();
+ int removedLines = rm_lines(&fld);
game.lines += removedLines;
switch (removedLines) {
case 1:
@@ -171,7 +132,7 @@ void tTick()
}
active.t = next.t;
resetActiveShape(&fld, &active);
- genNextShape();
+ gen_shape(&next);
checkLevelUp(&game);
}
sfClock_restart(putTick);
@@ -179,11 +140,6 @@ void tTick()
}
}
-
-
-
-
-
/*
* Keys hold handler
*
@@ -290,25 +246,6 @@ void tKeyCtrl()
}
}
-
-/*
- * Colorize active cells of active shape (overlay only
- * active cells above background of fld)
- *
- */
-void colorizeActive()
-{
- for (int j = 0; j < 4; j++)
- for (int i = 0; i < 4; i++)
- if (active.c[j][i] && j+active.y < 22) {
- sfRectangleShape_setFillColor(fld.p[j + active.y][i + active.x],
- active.fColor);
- sfRectangleShape_setOutlineColor(
- fld.p[j + active.y][i + active.x], UIFGACTIVECOLOR);
- }
-}
-
-
/*
* Draw all fld cells
*
@@ -320,9 +257,6 @@ void drawFld(sfRenderWindow *window)
sfRenderWindow_drawRectangleShape(window, fld.p[j][i], NULL);
}
-
-
-
void gameover(struct game *game)
{
game->isStarted = 0;
@@ -332,20 +266,6 @@ void gameover(struct game *game)
game->lines = 0;
}
-
-void genNextShape()
-{
- next.t = (rand() % 7) + 1; // Insert new random shape of 7 variants
- load_shape(&next);
- if (next.t == 5)
- for (int j = 0; j < 3; j++)
- for (int i = 0; i < 4; i++)
- next.c[i][j] = next.c[i][j+1];
-}
-
-
-
-
void drawNextShape(sfRenderWindow *window)
{
for (int j = 0; j < 4; j++)
@@ -357,11 +277,3 @@ void drawNextShape(sfRenderWindow *window)
}
}
-void freeFld() {
- for (int j = 0; j < fld.size.y; j++)
- for (int i = 0; i < fld.size.x; i++)
- sfRectangleShape_destroy(fld.p[j][i]);
- for (int j = 0; j < 4; j++)
- for (int i = 0; i < 4; i++)
- sfRectangleShape_destroy(next.p[j][i]);
-}