MULTITHREADED FOR EPICNESSSSSS

This commit is contained in:
2025-10-17 14:29:22 +02:00
parent 0e133aff32
commit f0e9d5c751
7 changed files with 148 additions and 95 deletions

View File

@@ -21,7 +21,7 @@ static rooster *get_maze(void) {
FILE *fh = fopen("assets/maze.txt", "r");
if (fh == NULL) {
perror("loading maze");
exit(EXIT_FAILURE);
return NULL;
}
rooster *rp = grid_from_file(fh);
fclose(fh);
@@ -29,7 +29,7 @@ static rooster *get_maze(void) {
// 3. Bepaal of het lezen van het rooster is gelukt.
if (rp == NULL) {
fprintf(stderr, "Kan rooster niet maken.\n");
exit(EXIT_FAILURE);
return NULL;
}
return rp;
@@ -53,7 +53,8 @@ static void maze_runner_beweeg(rooster *rp, int dx, int dy) {
if (playerx == -1 || playery == -1) {
printf("Player not found!");
exit(1);
rooster_zet_toestand(rp, STATE_BEGIN);
return;
}
if (rooster_bevat(rp, playerx + dx, playery + dy) == 1) {
@@ -113,11 +114,16 @@ static void speel_maze(rooster *rp) {
void maze_runner(void) {
// Voorbereiding.
rooster *rp = get_maze();
if (rp == NULL) {
return;
}
show_grid(rp);
rooster_zet_toestand(rp, STATE_AAN_HET_SPELEN);
// Game zelf.
speel_maze(rp);
while (rooster_vraag_toestand(rp) == STATE_AAN_HET_SPELEN) {
speel_maze(rp);
}
// Exit game.
game_exit_screen(rp);