2023-04-06 13:20:08 +00:00
|
|
|
#include "engine.hpp"
|
2023-04-07 22:26:52 +00:00
|
|
|
#include "corelib/assets.h"
|
|
|
|
#include "corelib/render.h"
|
2023-04-06 13:20:08 +00:00
|
|
|
#include "SDL2/SDL_image.h"
|
|
|
|
|
|
|
|
int engine_start() {
|
|
|
|
init_context();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int engine_shutdown() {
|
|
|
|
clean_assets();
|
|
|
|
close_context();
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void handle_events() {
|
|
|
|
while(SDL_PollEvent(&g_context.event)) {
|
|
|
|
switch(g_context.event.type) {
|
|
|
|
case SDL_QUIT:
|
|
|
|
g_context.running = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int engine_run() {
|
|
|
|
SDL_Window* window = SDL_CreateWindow("Tabletop", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 420, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
|
|
|
g_context = (context_t){
|
|
|
|
.window = window,
|
|
|
|
.renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED),
|
|
|
|
.running = 1,
|
|
|
|
};
|
|
|
|
load_game();
|
|
|
|
start_game();
|
|
|
|
while(g_context.running) {
|
|
|
|
handle_events();
|
|
|
|
_render_mode = 1;
|
2023-04-10 14:54:05 +00:00
|
|
|
update_ui();
|
2023-04-06 13:20:08 +00:00
|
|
|
_render_mode = 0;
|
2023-04-10 14:54:05 +00:00
|
|
|
update_game();
|
2023-04-06 13:20:08 +00:00
|
|
|
swap_buffer();
|
|
|
|
}
|
|
|
|
engine_shutdown();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
engine_start();
|
|
|
|
engine_run();
|
|
|
|
engine_shutdown();
|
|
|
|
}
|