#include "raylib.h" #include #include #include #include #include #include "game.h" #include "ui.h" static GameState_t game_state; int main() { srand(time(NULL)); FILE *game_file = fopen("save.dat", "rb"); if (game_file != NULL) { if (fread(&game_state, sizeof(GameState_t), 1, game_file) != 1) { reset_board(&game_state); } fclose(game_file); } else { reset_board(&game_state); } SetConfigFlags(FLAG_WINDOW_HIGHDPI); InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "2048"); SetTargetFPS(90); // We have event blocking so we can affort higher FPS EnableEventWaiting(); while (!WindowShouldClose()) { BeginDrawing(); ClearBackground(RAYWHITE); // If we are not animating, we can wait for input events instead of continuously rendering bool animating = render(&game_state); if (animating) { DisableEventWaiting(); } else { EnableEventWaiting(); } EndDrawing(); handle_mouse_input(&game_state); handle_keyboard_input(&game_state); } CloseWindow(); return 0; }