Window should close change
This commit is contained in:
parent
d260da4c25
commit
5de48b7507
@ -39,6 +39,7 @@ static GameState *init() {
|
|||||||
SetTargetFPS(TARGET_FPS);
|
SetTargetFPS(TARGET_FPS);
|
||||||
|
|
||||||
GameState *state = malloc(sizeof(struct GameApi));
|
GameState *state = malloc(sizeof(struct GameApi));
|
||||||
|
state->target_pos = (PointOption){ .tag = NONE };
|
||||||
state->num_boids = 16;
|
state->num_boids = 16;
|
||||||
state->max_speed = 5.0f;
|
state->max_speed = 5.0f;
|
||||||
state->max_force = 0.05;
|
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
|
// We need this so all the raylib state is in the right place
|
||||||
static bool should_close() {
|
static bool window_should_close() {
|
||||||
return WindowShouldClose();
|
return WindowShouldClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,5 +132,5 @@ const struct GameApi GAME_API = {
|
|||||||
.step = step,
|
.step = step,
|
||||||
.unload = unload,
|
.unload = unload,
|
||||||
.finalize = finalize,
|
.finalize = finalize,
|
||||||
.should_close = should_close,
|
.window_should_close = window_should_close,
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,7 @@ struct GameState;
|
|||||||
|
|
||||||
typedef struct GameApi {
|
typedef struct GameApi {
|
||||||
struct GameState *(*init)();
|
struct GameState *(*init)();
|
||||||
bool (*should_close)();
|
bool (*window_should_close)();
|
||||||
void (*finalize) (struct GameState *state);
|
void (*finalize) (struct GameState *state);
|
||||||
void (*reload) (struct GameState *state);
|
void (*reload) (struct GameState *state);
|
||||||
void (*unload) (struct GameState *state);
|
void (*unload) (struct GameState *state);
|
||||||
|
@ -17,8 +17,6 @@ struct Game {
|
|||||||
struct GameState* state;
|
struct GameState* state;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_EVENTS 1
|
|
||||||
|
|
||||||
void load_game(struct Game* game) {
|
void load_game(struct Game* game) {
|
||||||
struct stat attr;
|
struct stat attr;
|
||||||
if ((stat(GAME_LIB, &attr) == 0) && (game->gamelib_id != attr.st_ino)) {
|
if ((stat(GAME_LIB, &attr) == 0) && (game->gamelib_id != attr.st_ino)) {
|
||||||
@ -55,7 +53,7 @@ int main(void) {
|
|||||||
struct Game game = {0};
|
struct Game game = {0};
|
||||||
while (1) {
|
while (1) {
|
||||||
load_game(&game);
|
load_game(&game);
|
||||||
if (game.api.should_close()) {
|
if (game.api.window_should_close()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
game.api.step(game.state);
|
game.api.step(game.state);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user