Skip to content

Instantly share code, notes, and snippets.

@drakeirving
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drakeirving/64833e1ef543fc713a2b to your computer and use it in GitHub Desktop.
Save drakeirving/64833e1ef543fc713a2b to your computer and use it in GitHub Desktop.
Sound Handler
#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;
}
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