-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsound.h
166 lines (137 loc) · 2.14 KB
/
sound.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#ifndef SOUND_H
#define SOUND_H
#include "audio.h"
#include "commonvars.h"
#define musTitle 0
int prev_music = -1, current_music = -1, music_on = 0, sound_on = 0, force = 0;
int isMusicOn()
{
return music_on;
}
int isSoundOn()
{
return sound_on;
}
void initSound()
{
for (int i = 1; i < sound_channels; i++)
{
select_channel(i);
set_channel_volume(1.0);
}
}
void deInitSound()
{
}
void SelectMusic(int musicFile)
{
if(!music_on)
return;
if((musicFile != current_music) || force)
{
force = 0;
prev_music = current_music;
current_music = musicFile;
select_sound(current_music);
set_sound_loop(true);
play_sound_in_channel(current_music, 0);
}
}
void initMusic()
{
prev_music = -1;
current_music = -1;
select_channel(0);
set_channel_volume(0.55);
}
void stopSound()
{
for (int i = 1; i < sound_channels; i++)
stop_channel(i);
}
void setSoundOn(int value)
{
sound_on = value;
if(!sound_on)
stopSound();
}
void playSound(int soundID, bool repeat)
{
if (!sound_on)
{
return;
}
select_sound(soundID);
set_sound_loop(repeat);
play_sound(soundID);
}
void playLevelDoneSound()
{
playSound(8, false);
}
void playPickupSound()
{
playSound(6, false);
}
void playDropSound()
{
playSound(2, false);
}
void playWalkSound()
{
playSound(9, false);
}
void playJumpSound()
{
playSound(4, false);
}
void playFallSound()
{
playSound(3, false);
}
void playMenuSelectSound()
{
playSound(7, false);
}
void playMenuBackSound()
{
playSound(1, false);
}
void playMenuSound()
{
playSound(5, false);
}
void stopMusic()
{
stop_channel(0);
}
void deInitMusic()
{
stopMusic();
}
void setMusicOn(int value)
{
music_on = value;
if(music_on)
{
if (prev_music != -1)
{
force = 1;
SelectMusic(prev_music);
}
else
{
//for options screen
if(GameState == GSTitleScreen)
{
force = 1;
SelectMusic(musTitle);
}
}
}
else
{
stopMusic();
}
}
#endif