Cleaner Database

Talk about making games.

Cleaner Database

Postby Hblade » Sat Mar 06, 2010 9:23 pm

You can load sounds / music from a different location, such as an "Audio" folder using this.

heres the straight code:

Make 3 variables called :
SoundLocation(string)
MusicLocation(string)
soundvol(real)

Then put this code in Global Code
Code: Select all
#define HIGH 0
#define MEDIUM 1
#define LOW 2
#define LEFT -1
#define MIDDLE 0
#define RIGHT 1
void playBGM(char *fileName, int Priority)
{
    sprintf(MusicLocation, "Audio/Music/%s", fileName);
    switch(Priority)
    {
        case 0:
        PlayMusic2(MusicLocation, musicvol, 0, HIGH_PRIORITY_MUSIC);
        break;
        case 1:
        PlayMusic2(MusicLocation, musicvol, 0, MEDIUM_PRIORITY_MUSIC);
        break;
        case 2:
        PlayMusic2(MusicLocation, musicvol, 0, MEDIUM_PRIORITY_MUSIC);
        break;
    }
}

void playSE(char *fileName)
{
    sprintf(SoundLocation, "Audio\\Sounds\\%s", fileName);
    PlaySound2(SoundLocation, soundvol, 1, 0.000000);
}


The Left, Middle, and Right definitions arn't used yet.

To call this function, simply:

playBGM("Filename.ogg", HIGH);

HIGH means High Priority.

playSE("File name.wav");

Plays a sound effect.

Look in the code to change the directory of your music / sound files.

Demo:
Clean Database.zip
(1012.77 KiB) Downloaded 42 times


The reason the demo is so big in file size is because of the fact that it has audio files in it :3
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron