Rev 1 | Rev 18 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 11 | ||
---|---|---|---|
Line 9... | Line 9... | ||
9 | 9 | ||
10 | void Audio_Think (void) |
10 | void Audio_Think (void) |
11 | { |
11 | { |
12 | // this function plays the queued sounds on the right time |
12 | // this function plays the queued sounds on the right time |
13 | 13 | ||
- | 14 | static wchar_t soundfile_path[MAX_PATH]; |
|
14 | int sound_index; |
15 | int sound_index; |
15 | 16 | ||
16 | // do we have a sound to play ? if so, play it |
17 | // do we have a sound to play ? if so, play it |
17 | if (queued_sound != 0) |
18 | if (queued_sound != 0) |
18 | { |
19 | { |
19 | // given the type of sound we want, enqueue the right one |
20 | // given the type of sound we want, enqueue the right one |
20 | if (queued_sound == SOUNDTYPE_CLICK) |
21 | if (queued_sound == SOUNDTYPE_CLICK) |
21 |
|
22 | swprintf_s (soundfile_path, WCHAR_SIZEOF (soundfile_path), L"%s/data/sounds/click.wav", app_path); |
22 | else if (queued_sound == SOUNDTYPE_ILLEGALMOVE) |
23 | else if (queued_sound == SOUNDTYPE_ILLEGALMOVE) |
23 |
|
24 | swprintf_s (soundfile_path, WCHAR_SIZEOF (soundfile_path), L"%s/data/sounds/illegal.wav", app_path); |
24 | else if (queued_sound == SOUNDTYPE_VICTORY) |
25 | else if (queued_sound == SOUNDTYPE_VICTORY) |
25 |
|
26 | swprintf_s (soundfile_path, WCHAR_SIZEOF (soundfile_path), L"%s/data/sounds/win.wav", app_path); |
26 | else if (queued_sound == SOUNDTYPE_DEFEAT) |
27 | else if (queued_sound == SOUNDTYPE_DEFEAT) |
27 |
|
28 | swprintf_s (soundfile_path, WCHAR_SIZEOF (soundfile_path), L"%s/data/sounds/lose.wav", app_path); |
28 | else if (queued_sound == SOUNDTYPE_CHECK) |
29 | else if (queued_sound == SOUNDTYPE_CHECK) |
29 |
|
30 | swprintf_s (soundfile_path, WCHAR_SIZEOF (soundfile_path), L"%s/data/sounds/check.wav", app_path); |
30 | else if (queued_sound == SOUNDTYPE_PIECETAKEN) |
31 | else if (queued_sound == SOUNDTYPE_PIECETAKEN) |
31 |
|
32 | swprintf_s (soundfile_path, WCHAR_SIZEOF (soundfile_path), L"%s/data/sounds/take.wav", app_path); |
32 | else if (queued_sound == SOUNDTYPE_MOVE) |
33 | else if (queued_sound == SOUNDTYPE_MOVE) |
33 | { |
34 | { |
34 | sound_index = rand () % 6; // there are several movement sounds, pick one at random |
35 | sound_index = rand () % 6; // there are several movement sounds, pick one at random |
35 | if (sound_index == 0) |
36 | if (sound_index == 0) |
36 |
|
37 | swprintf_s (soundfile_path, WCHAR_SIZEOF (soundfile_path), L"%s/data/sounds/move1.wav", app_path); |
37 | else if (sound_index == 1) |
38 | else if (sound_index == 1) |
38 |
|
39 | swprintf_s (soundfile_path, WCHAR_SIZEOF (soundfile_path), L"%s/data/sounds/move2.wav", app_path); |
39 | else if (sound_index == 2) |
40 | else if (sound_index == 2) |
40 |
|
41 | swprintf_s (soundfile_path, WCHAR_SIZEOF (soundfile_path), L"%s/data/sounds/move3.wav", app_path); |
41 | else if (sound_index == 3) |
42 | else if (sound_index == 3) |
42 |
|
43 | swprintf_s (soundfile_path, WCHAR_SIZEOF (soundfile_path), L"%s/data/sounds/move4.wav", app_path); |
43 | else if (sound_index == 4) |
44 | else if (sound_index == 4) |
44 |
|
45 | swprintf_s (soundfile_path, WCHAR_SIZEOF (soundfile_path), L"%s/data/sounds/move5.wav", app_path); |
45 | else |
46 | else |
46 |
|
47 | swprintf_s (soundfile_path, WCHAR_SIZEOF (soundfile_path), L"%s/data/sounds/move6.wav", app_path); |
47 | } |
48 | } |
48 | 49 | ||
- | 50 | PlaySound (soundfile_path, NULL, SND_ASYNC | SND_FILENAME | SND_NODEFAULT); |
|
49 | queued_sound = 0; // play this sound then forget it |
51 | queued_sound = 0; // play this sound then forget it |
50 | } |
52 | } |
51 | 53 | ||
52 | return; // finished, audio has been handled |
54 | return; // finished, audio has been handled |
53 | } |
55 | } |