From 5de48b750770d114f2ca92da8c1589ea77a6c557 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Sun, 10 Nov 2024 11:13:32 +0700 Subject: [PATCH] Window should close change --- boids_game.c | 5 +++-- boids_game.h | 2 +- boids_main.c | 4 +--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/boids_game.c b/boids_game.c index e6f91fe..6133693 100644 --- a/boids_game.c +++ b/boids_game.c @@ -39,6 +39,7 @@ static GameState *init() { SetTargetFPS(TARGET_FPS); GameState *state = malloc(sizeof(struct GameApi)); + state->target_pos = (PointOption){ .tag = NONE }; state->num_boids = 16; state->max_speed = 5.0f; state->max_force = 0.05; @@ -80,7 +81,7 @@ static void unload(GameState *state) { } // We need this so all the raylib state is in the right place -static bool should_close() { +static bool window_should_close() { return WindowShouldClose(); } @@ -131,5 +132,5 @@ const struct GameApi GAME_API = { .step = step, .unload = unload, .finalize = finalize, - .should_close = should_close, + .window_should_close = window_should_close, }; diff --git a/boids_game.h b/boids_game.h index 25edde9..fc51e7d 100644 --- a/boids_game.h +++ b/boids_game.h @@ -4,7 +4,7 @@ struct GameState; typedef struct GameApi { struct GameState *(*init)(); - bool (*should_close)(); + bool (*window_should_close)(); void (*finalize) (struct GameState *state); void (*reload) (struct GameState *state); void (*unload) (struct GameState *state); diff --git a/boids_main.c b/boids_main.c index dab2657..89e8fc1 100644 --- a/boids_main.c +++ b/boids_main.c @@ -17,8 +17,6 @@ struct Game { struct GameState* state; }; -#define MAX_EVENTS 1 - void load_game(struct Game* game) { struct stat attr; if ((stat(GAME_LIB, &attr) == 0) && (game->gamelib_id != attr.st_ino)) { @@ -55,7 +53,7 @@ int main(void) { struct Game game = {0}; while (1) { load_game(&game); - if (game.api.should_close()) { + if (game.api.window_should_close()) { break; } game.api.step(game.state);