41 lines
847 B
C
41 lines
847 B
C
#include "raylib.h"
|
|
#include <math.h>
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
|
|
#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(30); // So my laptop doesn't burn
|
|
|
|
while (!WindowShouldClose()) {
|
|
ClearBackground(RAYWHITE);
|
|
BeginDrawing();
|
|
render(&game_state);
|
|
EndDrawing();
|
|
handle_mouse_input(&game_state);
|
|
handle_keyboard_input(&game_state);
|
|
}
|
|
CloseWindow();
|
|
return 0;
|
|
}
|