Back to shtanton's homepage
summaryrefslogtreecommitdiff
path: root/src/tick.c
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2025-04-06 22:26:55 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2025-04-06 22:26:55 +0100
commitbd31dd79eb31b76f3d7276be8dfaff21f615b1da (patch)
treeef1b4edf40d34b3da3928008ce032f5a05e23c32 /src/tick.c
parentacef84852c11b6e154535251d5e3a4ffb3a2cf8f (diff)
downloadldjam57-bd31dd79eb31b76f3d7276be8dfaff21f615b1da.tar
Adds many new levels
Diffstat (limited to 'src/tick.c')
-rw-r--r--src/tick.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/tick.c b/src/tick.c
index a15c1cb..21cf578 100644
--- a/src/tick.c
+++ b/src/tick.c
@@ -27,6 +27,10 @@ static void tick(Game *game, Arena a) {
State *lastState = new(&a, 1, State);
xmemcpy(lastState, game, sizeof(State));
+ if (lastState->spawnerCount > 0) {
+ game->state.spawnerCount = lastState->spawnerCount - 1;
+ }
+
for (int x = 0; x < GRIDWIDTH; x++) {
for (int y = 0; y < GRIDHEIGHT; y++) {
switch (lastState->grid[x + y * GRIDWIDTH]) {
@@ -180,6 +184,20 @@ static void tick(Game *game, Arena a) {
}
break;
case BLUE:
+ // Win condition
+ if (game->state.goalx == x && game->state.goaly == y) {
+ if (!game->state.need9) {
+ game->state.levelComplete = 1;
+ } else {
+ if (game->state.blues < 9) {
+ game->state.blues++;
+ if (game->state.blues == 9) {
+ game->state.levelComplete = 1;
+ }
+ }
+ }
+ game->state.grid[x + y * GRIDWIDTH] = EMPTY;
+ }
blues = 0;
if (
x > 0 && (
@@ -336,14 +354,23 @@ static void tick(Game *game, Arena a) {
} else if (blues >= 2) {
game->state.grid[x + y * GRIDWIDTH] = BLUE;
}
+
+ // Spawner
+ if (
+ game->state.spawnerx != 0 &&
+ game->state.spawnery != 0 &&
+ game->state.grid[x + y * GRIDWIDTH] == EMPTY &&
+ x == game->state.spawnerx &&
+ y == game->state.spawnery &&
+ lastState->spawnerCount == 0
+ ) {
+ game->state.grid[x + y * GRIDWIDTH] = BLUE;
+ game->state.spawnerCount = levels[game->state.currentLevel].spawnRate;
+ }
break;
}
}
}
-
- if (game->state.grid[game->state.goalx + game->state.goaly * GRIDWIDTH] == BLUE) {
- game->state.levelComplete = 1;
- }
}
#endif // INCLUDE_TICK_C