MULTITHREADED FOR EPICNESSSSSS
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user