-
-
Save drakeirving/64833e1ef543fc713a2b to your computer and use it in GitHub Desktop.
Sound Handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "./lib_sounds.dnh" | |
let dir = GetCurrentScriptDirectory(); | |
@Initialize { } | |
@MainLoop { } | |
@Event{ | |
if(GetEventType() == EV_USER+193){ | |
ObjSound_Play( ALL_SOUNDS[GetEventArgument(0)] ); | |
} | |
} | |
let ALL_SOUNDS = [ | |
PrepareSE(dir~"shot.wav"), // SE_SHOT | |
PrepareSE(dir~"shot2.wav"), // SE_SHOT2 | |
PrepareSE(dir~"charge.wav"), // SE_CHARGE | |
PrepareSE(dir~"explode.wav") // SE_EXPLODE | |
]; | |
function PrepareSE(path){ | |
let se = ObjSound_Create(); | |
ObjSound_Load(se, path); | |
ObjSound_SetLoopEnable(se, false); | |
ObjSound_SetSoundDivision(se, SOUND_SE); | |
return se; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let SE_SHOT = 0; | |
let SE_SHOT2 = 1; | |
let SE_CHARGE = 2; | |
let SE_EXPLODE = 3; | |
function _PlaySE(id){ | |
NotifyEventAll(EV_USER+193, id); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment