Game state is now preserved in a file

This commit is contained in:
2026-03-06 19:03:55 +01:00
parent 4c21d309e9
commit 016b1eafb5
5 changed files with 27 additions and 6 deletions
+8
View File
@@ -1,6 +1,7 @@
#include "raylib.h"
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
@@ -30,6 +31,13 @@ int main() {
srand(time(NULL));
reset_board(&game_state);
FILE* game_file = fopen("save.dat", "rb");
if (game_file != NULL) {
fseek(game_file, 0, SEEK_SET);
fread(&game_state, sizeof(GameState_t), 1, game_file);
fclose(game_file);
}
InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "2048");
SetTargetFPS(30); // So my laptop doesn't burn