Game state is now preserved in a file
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <math.h>
|
||||
#include <raylib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static bool is_dragging;
|
||||
static Vector2 drag_start_pos;
|
||||
@@ -55,15 +56,20 @@ void handle_mouse_input(GameState_t *game_state) {
|
||||
return;
|
||||
}
|
||||
// TODO: Allow for infinite play
|
||||
for(int y = 0; y < BOARD_HEIGHT; y++) {
|
||||
for(int x = 0; x < BOARD_WIDTH; x++) {
|
||||
if(game_state->board[y][x] == 2048) {
|
||||
for (int y = 0; y < BOARD_HEIGHT; y++) {
|
||||
for (int x = 0; x < BOARD_WIDTH; x++) {
|
||||
if (game_state->board[y][x] == 2048) {
|
||||
game_state->status = WON;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FILE *f = fopen("save.dat", "wb");
|
||||
if (f) {
|
||||
fwrite(game_state, sizeof(GameState_t), 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
is_dragging = false;
|
||||
|
||||
Reference in New Issue
Block a user