A retro platform game
git clone git://soophie.de/freezo
blob: 6f0d2218976a66b5794a2cb4650e07246a35c927 (1205 bytes)[doc][blame][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
game = game_create();38
SetTargetFPS(60);39
SetExitKey(0);40
#if defined(PLATFORM_WEB)41
emscripten_set_main_loop(do_update, 0, 1);42
#else43
struct sigaction sigint_action;44
sigint_action.sa_handler = handle_segfault;45
sigint_action.sa_flags = 0;46
sigemptyset(&sigint_action.sa_mask);47
sigaction(SIGSEGV, &sigint_action, NULL);48
while (!game->quit && !WindowShouldClose()) {49
do_update();50
}51
#endif52
CloseWindow();53
game_free(game);54
return 0;55
}