add sound

This commit is contained in:
asrael 2026-01-07 17:45:46 -06:00
parent 99d9c43ea3
commit 01d6e09a91
22 changed files with 1825 additions and 39 deletions

View file

@ -218,12 +218,19 @@ pxl8_result pxl8_init(pxl8* sys, i32 argc, char* argv[]) {
return PXL8_ERROR_INITIALIZATION_FAILED;
}
game->mixer = pxl8_sfx_mixer_create();
if (!game->mixer) {
pxl8_error("failed to create audio mixer");
return PXL8_ERROR_INITIALIZATION_FAILED;
}
if (game->repl_mode) {
pxl8_info("starting in REPL mode with script: %s", game->script_path);
}
pxl8_script_set_gfx(game->script, game->gfx);
pxl8_script_set_input(game->script, &game->input);
pxl8_script_set_sfx(game->script, game->mixer);
pxl8_script_set_sys(game->script, sys);
if (game->script_path[0] != '\0') {
@ -364,6 +371,7 @@ void pxl8_quit(pxl8* sys) {
pxl8_cart_unmount(sys->cart);
}
pxl8_sfx_mixer_destroy(game->mixer);
pxl8_gfx_destroy(game->gfx);
pxl8_script_destroy(game->script);
}
@ -394,6 +402,10 @@ pxl8_input_state* pxl8_get_input(const pxl8* sys) {
return (sys && sys->game) ? &sys->game->input : NULL;
}
pxl8_sfx_mixer* pxl8_get_sfx_mixer(const pxl8* sys) {
return (sys && sys->game) ? sys->game->mixer : NULL;
}
void pxl8_center_cursor(pxl8* sys) {
if (!sys || !sys->hal || !sys->hal->center_cursor) return;
sys->hal->center_cursor(sys->platform_data);