Game state is now preserved in a file
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user