-
Notifications
You must be signed in to change notification settings - Fork 1
/
gamesound.h
80 lines (65 loc) · 1.58 KB
/
gamesound.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
#ifndef GAMESOUND_H
#define GAMESOUND_H
#include <QList>
#include <QTimer>
#ifdef Q_OS_WIN32
#include "SDL.h"
#include "SDL_mixer.h"
#else
#include "SDL/SDL.h"
#include "SDL/SDL_mixer.h"
#endif
class GameSound : public QObject
{
Q_OBJECT
public:
GameSound();
~GameSound();
enum Sounds {
sndItemDisappear = 0,
sndSmallHammer = 1,
sndUnblock = 2,
sndHammer = 3,
sndBigHammer = 4,
sndBomb = 5,
sndRow = 6,
sndRandomKill = 7,
sndMixer = 8,
sndTwin = 9,
sndClock = 10,
sndBonus = 11,
sndNewItem = 12,
sndTarget = 13,
sndLevelStart = 14,
sndLevelFail = 15,
sndLevelWon = 16,
sndBeep = 17,
sndBonusGot,
sndTool
};
Mix_Chunk* loadSound(const QString &filename);
void playSound(int index, int loops = 1);
void stopSound(int index);
void stopAllSounds();
void setChannelVolume(int val, int ch = -1);
int soundVolume() const { return channel_vol; }
void loadMusic(const QString &filename);
void playMusic();
void stopMusic();
void setMusicVolume(int val);
int musicVolume() const { return music_vol; }
inline bool isMusicEnabled() const { return musicEnabled; }
void enableMusic(bool on = true);
private slots:
void checkPlayMusic();
signals:
void musicFinished();
private:
QList<Mix_Chunk*> m_sounds;
int music_vol, channel_vol;
Mix_Music *music;
QTimer *myTimer;
bool musicEnabled, musicPlaying;
};
extern GameSound* sndEngine;
#endif // GAMESOUND_H