-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
54 lines (54 loc) · 1.28 KB
/
main.cpp
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
51
52
53
54
#include <SDL.h>
#include <SDL_ttf.h>
#include <cstdio>
#include <cstdlib>
#include "button.h"
using namespace std;
TTF_Font *font = NULL;
SDL_Window *window = NULL;
SDL_Renderer *renderer = NULL;
SDL_Event event;
Button quit;
int WinMain() {
SDL_Init(SDL_INIT_EVERYTHING);
TTF_Init();
font = TTF_OpenFont("OpenSans.ttf", 24);
window = SDL_CreateWindow("MineSonny",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
804, 480,
SDL_WINDOW_RESIZABLE);
renderer = SDL_CreateRenderer(window, -1, 0);
SDL_GetWindowSurface(window);
atexit(SDL_Quit);
atexit(TTF_Quit);
bool apprun = true;
int menu = 0;
bool shown = false;
while (apprun) {
if (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
exit(0);
} else if (event.type == SDL_MOUSEBUTTONUP) {
if (menu == 0 && shown == false) {
quit.setX(595);
quit.setY(400);
quit.setW(200);
quit.setH(70);
quit.setText("Quit");
quit.render(renderer, font);
shown = true;
printf("Render main menu\n");
}
} else if (event.type == SDL_WINDOWEVENT) {
if (menu == 0) {
quit.render(renderer, font);
printf("Render main menu\n");
}
SDL_UpdateWindowSurface(window);
printf("Update window surface\n");
}
}
SDL_RenderPresent(renderer);
}
return 0;
}