|
|
|
@ -47,7 +47,7 @@ struct SDL_Window* make_window(void) {
@@ -47,7 +47,7 @@ struct SDL_Window* make_window(void) {
|
|
|
|
|
return SDL_CreateWindow("space_game",
|
|
|
|
|
SDL_WINDOWPOS_UNDEFINED,
|
|
|
|
|
SDL_WINDOWPOS_UNDEFINED,
|
|
|
|
|
1000, 1000,
|
|
|
|
|
1920, 1080,
|
|
|
|
|
SDL_WINDOW_SHOWN);
|
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
@ -60,7 +60,7 @@ void redraw(struct SDL_Renderer * ren) {
@@ -60,7 +60,7 @@ void redraw(struct SDL_Renderer * ren) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int physics_loop(void *ptr) { |
|
|
|
|
game_paused = 1; |
|
|
|
|
game_paused = 0; |
|
|
|
|
while (1) { |
|
|
|
|
if (step()) { |
|
|
|
|
// display end level screen
|
|
|
|
@ -87,14 +87,12 @@ int physics_loop(void *ptr) {
@@ -87,14 +87,12 @@ int physics_loop(void *ptr) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void mainloop(void *ren) { |
|
|
|
|
step(); |
|
|
|
|
|
|
|
|
|
printf("main loop\n"); |
|
|
|
|
if (!in_game) { |
|
|
|
|
draw_end_screen(ren); |
|
|
|
|
} else { |
|
|
|
|
redraw(ren); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int game(void) { |
|
|
|
@ -152,14 +150,13 @@ int game(void) {
@@ -152,14 +150,13 @@ int game(void) {
|
|
|
|
|
if (eee) |
|
|
|
|
printf("startgame(): %s\n", eee), SDL_ClearError();
|
|
|
|
|
|
|
|
|
|
#ifndef EMSCRIPTEN |
|
|
|
|
#ifdef __EMSCRIPTEN__ |
|
|
|
|
emscripten_set_main_loop_arg(mainloop, ren, -1, 1); |
|
|
|
|
#else |
|
|
|
|
SDL_Thread *physics_thread; |
|
|
|
|
physics_thread = SDL_CreateThread(physics_loop, "physics", (void *)ren); |
|
|
|
|
#else |
|
|
|
|
emscripten_set_main_loop_arg(mainloop, ren, -1, 1/*block*/); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int count = 0; |
|
|
|
|
int close = 0; |
|
|
|
|
|
|
|
|
@ -189,14 +186,15 @@ emscripten_set_main_loop_arg(mainloop, ren, -1, 1/*block*/);
@@ -189,14 +186,15 @@ emscripten_set_main_loop_arg(mainloop, ren, -1, 1/*block*/);
|
|
|
|
|
} |
|
|
|
|
/* Redraw Screen */ |
|
|
|
|
#ifdef __EMSCRIPTEN__ |
|
|
|
|
step(); |
|
|
|
|
|
|
|
|
|
if (!in_game) { |
|
|
|
|
draw_end_screen(ren); |
|
|
|
|
} else { |
|
|
|
|
redraw(ren); |
|
|
|
|
printf("step loop\n"); |
|
|
|
|
/*
|
|
|
|
|
if (step()) { |
|
|
|
|
// display end level screen
|
|
|
|
|
in_game = false; |
|
|
|
|
next_level(); |
|
|
|
|
in_game = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|