A retro platform game
git clone git://soophie.de/freezo
blob: acc22a732fd107da6cc9c1324f7460898824fb06 (1375 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
if (!IsSoundPlaying(game->assets.track)) {29
PlaySound(game->assets.track);30
}31
game_update(game);32
game_draw(game);33
}35
int main(void) {36
printf("PID: %d\n", getpid());37
time_t t;38
srand((unsigned) time(&t));39
InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Freezo");40
InitAudioDevice();41
game = game_create();42
SetSoundVolume(game->assets.track, 0.5);43
SetTargetFPS(60);44
SetExitKey(0);45
#if defined(PLATFORM_WEB)46
emscripten_set_main_loop(do_update, 0, 1);47
#else48
struct sigaction sigint_action;49
sigint_action.sa_handler = handle_segfault;50
sigint_action.sa_flags = 0;51
sigemptyset(&sigint_action.sa_mask);52
sigaction(SIGSEGV, &sigint_action, NULL);53
while (!game->quit && !WindowShouldClose()) {54
do_update();55
}56
#endif57
CloseAudioDevice();58
CloseWindow();59
game_free(game);60
return 0;61
}