A retro platform game
git clone git://soophie.de/freezo
blob: e581038c0e3e4cd22554eed5e9b4617fa17abc64 (1248 bytes)[raw]
1
#include <stdio.h>2
#include <stdlib.h>3
#include <signal.h>4
#include <unistd.h>5
#include <time.h>7
#include "../include/game.h"8
#include "../include/const.h"9
#include "../lib/raylib.h"11
#if defined(PLATFORM_WEB)12
#include <emscripten/emscripten.h>13
#else14
#include <execinfo.h>16
void handle_segfault(int signal) {17
void *list[10];18
size_t size = backtrace(list, 10);19
fprintf(stderr, "ERROR: signal %d:\n", signal);20
backtrace_symbols_fd(list, size, STDERR_FILENO);21
exit(1);22
}23
#endif25
game_t *game = NULL;27
void do_update(void) {28
game_update(game);29
game_draw(game);30
}32
int main(void) {33
printf("PID: %d\n", getpid());34
time_t t;35
srand((unsigned) time(&t));36
InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Freezo");37
InitAudioDevice();38
game = game_create();39
SetTargetFPS(60);40
SetExitKey(0);41
#if defined(PLATFORM_WEB)42
emscripten_set_main_loop(do_update, 0, 1);43
#else44
struct sigaction sigint_action;45
sigint_action.sa_handler = handle_segfault;46
sigint_action.sa_flags = 0;47
sigemptyset(&sigint_action.sa_mask);48
sigaction(SIGSEGV, &sigint_action, NULL);49
while (!game->quit && !WindowShouldClose()) {50
do_update();51
}52
#endif53
CloseAudioDevice();54
CloseWindow();55
game_free(game);56
return 0;57
}