aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
blob: 746ee698da43a22acbc8abbdba4ed7b33480f42e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#define SDL_MAIN_HANDLED

#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>

#include "globals.hpp"
#include "framework/window.hpp"
#include "minesweeper/ui.hpp"

int main(int argc, char** argv) {
    (void)argc; (void)argv;

    SDL_Init(SDL_INIT_VIDEO);
#ifdef SHOW_DEBUG_HELPERS
    Utils::CheckSDLError("main::SDL_Init");
#endif

    IMG_Init(IMG_INIT_PNG);
#ifdef SHOW_DEBUG_HELPERS
    Utils::CheckSDLError("main::IMG_Init");
#endif

    TTF_Init();
#ifdef SHOW_DEBUG_HELPERS
    Utils::CheckSDLError("main::TTF_Init");
#endif

    Framework::Window GameWindow;
    MinesweeperUI UI;
    SDL_Event Event;
    bool gameRun{ true };

    while (gameRun) {
	while (SDL_PollEvent(&Event)) {
	   if (Event.type == SDL_QUIT) {
		gameRun = false;
	   } else {
		UI.HandleEvent(Event);
	   }
	}
	GameWindow.Render();
	UI.Render(GameWindow.GetSurface());
	GameWindow.Update();
    }

    SDL_Quit();
    return 0;
}

(git 2.53.0) at 2026-05-09 09:41:07 +0000