-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
40 lines (33 loc) · 878 Bytes
/
main.cpp
File metadata and controls
40 lines (33 loc) · 878 Bytes
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
#define SDL_MAIN_USE_CALLBACKS 1
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <time.h>
#include <stdlib.h>
#include "game.h"
#include "pdaudio.h"
static Game* game = nullptr;
SDL_AppResult SDL_AppInit(void** appstate, int argc, char* argv[]) {
srand(time(NULL));
game = new Game();
game->difficulty = 0;
game->music_mode = Game::MUSIC_OFF;
game->fullscreen = 1.0f;
game->init_graphics();
pd_init();
*appstate = game;
return SDL_APP_CONTINUE;
}
SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) {
return ((Game*)appstate)->handle_event(*event);
}
SDL_AppResult SDL_AppIterate(void* appstate) {
return ((Game*)appstate)->iterate();
}
void SDL_AppQuit(void* appstate, SDL_AppResult result) {
pd_shutdown();
if (game) {
game->shutdown();
delete game;
game = nullptr;
}
}