Add mixer to Emscripten port, fix a surprisingly long-lasting oversight

where SDL_Delay wouldn't work properly because a float was passed
implying SECONDS instead of MILLISECONDS
This commit is contained in:
blitzdoughnuts 2025-01-13 16:17:55 -05:00
parent deb15aad0c
commit 90613ed2a8
3 changed files with 7 additions and 5 deletions

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
WakeToHell*
WakeToHell
WakeToHellSAF
*.exe
*.dll
packaging/usr/games/waketohell/*

View file

@ -540,10 +540,10 @@ void gameLoop() {
SDL_DestroyRenderer(render);
SDL_DestroyWindow(win);
SDL_Quit();
#ifdef __EMSCRIPTEN
emscripten_cancel_main_loop();
#endif
SDL_Quit();
return;
};
while (SDL_PollEvent(&event)) {
@ -608,7 +608,7 @@ void gameLoop() {
#ifdef WTH_DEBUG
SDL_Delay(DEBUG_gameFPS);
#else
SDL_Delay(1.0f / GAME_FPS);
SDL_Delay((uint32_t)(1.0f / GAME_FPS * 1000));
#endif
};
@ -732,7 +732,9 @@ int main(int argc, char *argv[]) {
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(gameLoop, 0, 1);
#else
while (running) gameLoop();
while (running) {
gameLoop();
};
#endif
return 0;
};

View file

@ -21,7 +21,7 @@ if [ $1 = "sdl" ]; then
./WakeToHell
fi
elif [ $1 = "em" ]; then
emcc main_sdl.c -DWTH_NOSOUND -s USE_SDL=2 -s USE_SDL_IMAGE=2 -o WakeToHell.html --use-preload-plugins --preload-file sprites
emcc main_sdl.c -DGAME_FPS=30 -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_MIXER=2 -o WakeToHell.html --use-preload-plugins --preload-file sprites --preload-file sfx --preload-file NMARE.mid
if [[ $AUTORUN -ne 0 && $? -eq 0 ]]; then
emrun WakeToHell.html
fi