Ok, here is your code. Everything should be self-explanatory
#include "DarkGDK.h"
#include <Dinput.h>
void PlaySoundOnce (int sID, char keynumber, char* fx)
{
if ( dbKeyState ( keynumber ) )
{
if ( fx == "sound" )
{
dbPlaySound ( sID );
}
else
{
if ( dbMusicPlaying ( sID ) )
dbStopMusic ( sID );
dbPlayMusic ( sID );
}
dbWaitKey();
}
}
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 120 );
dbLoadSound ( "battle026.wav", 1 );
dbLoadMusic ( "solwatch.mid", 2 );
while ( LoopGDK ( ) )
{
// here we make a call to update the contents of the screen
dbSync ( );
PlaySoundOnce ( 1, DIK_F1, "sound" ); // Use this to assign the music or sound
PlaySoundOnce ( 2, DIK_F2, "music" );
}
return;
}
Here's how it works:
PlaySoundOnce ( Sound ID of music or sound you loaded, DirectX macro key, music or sound )
The first argument takes the music or sound you loaded. Make sure you use dbLoadMusic for large music (midi's etc) and dbLoadSound for short music.
The second argument is the directx macro. Like DIK_F1 or DIK_32 etc.
The third argument is the declaration. You have to tell it if you loaded the music as a sound (dbLoadSound) or music (dbLoadMusic).
Cheers,
dbGamerX
dbPrint ( "Sig" );