summaryrefslogtreecommitdiffstats
path: root/pacman-c++
diff options
context:
space:
mode:
Diffstat (limited to 'pacman-c++')
-rw-r--r--pacman-c++/audio.cpp26
-rw-r--r--pacman-c++/constants.h7
-rw-r--r--pacman-c++/server.cpp4
3 files changed, 22 insertions, 15 deletions
diff --git a/pacman-c++/audio.cpp b/pacman-c++/audio.cpp
index d74445a..8726899 100644
--- a/pacman-c++/audio.cpp
+++ b/pacman-c++/audio.cpp
@@ -1,4 +1,5 @@
1#include "audio.h" 1#include "audio.h"
2#include "constants.h"
2#include <phonon/AudioOutput> 3#include <phonon/AudioOutput>
3#include <QCoreApplication> 4#include <QCoreApplication>
4#include <QTimer> 5#include <QTimer>
@@ -13,18 +14,19 @@ bool AudioManager::m_working = false;
13AudioManager::AudioManager() 14AudioManager::AudioManager()
14 : m_muted(true) 15 : m_muted(true)
15{ 16{
16#ifdef SERVER 17 if (Constants::server)
17 qDebug() << "Server has no sound" 18 qDebug() << "Server has no sound";
18#else 19 else
19 preload(); 20 {
20 21 preload();
21 AudioPlayer *firstplayer = new AudioPlayer(this); 22
22 firstplayer->test(m_sounds[Sound::WakaWaka]); 23 AudioPlayer *firstplayer = new AudioPlayer(this);
23 m_working = firstplayer->m_working; 24 firstplayer->test(m_sounds[Sound::WakaWaka]);
24 m_players.append(firstplayer); 25 m_working = firstplayer->m_working;
25 26 m_players.append(firstplayer);
26 m_muted = false; 27
27#endif // SERVER 28 m_muted = false;
29 }
28} 30}
29 31
30AudioManager *AudioManager::self() 32AudioManager *AudioManager::self()
diff --git a/pacman-c++/constants.h b/pacman-c++/constants.h
index aacc964..90963fe 100644
--- a/pacman-c++/constants.h
+++ b/pacman-c++/constants.h
@@ -15,13 +15,16 @@ namespace Constants {
15 const unsigned int sprite_margin = 2; 15 const unsigned int sprite_margin = 2;
16 const unsigned int sprite_offset = 20; 16 const unsigned int sprite_offset = 20;
17 const unsigned int tick = 250; // ms 17 const unsigned int tick = 250; // ms
18 static bool server = false;
18 19
19 namespace Networking { 20 namespace Networking
21 {
20 const unsigned int port = 7321; 22 const unsigned int port = 7321;
21 const unsigned int connection_timeout = 3000; 23 const unsigned int connection_timeout = 3000;
22 } 24 }
23 25
24 namespace Game { 26 namespace Game
27 {
25 const unsigned int bonus_point_value = 100; 28 const unsigned int bonus_point_value = 100;
26 const unsigned int point_value = 10; 29 const unsigned int point_value = 10;
27 } 30 }
diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp
index 4656238..18ec8fa 100644
--- a/pacman-c++/server.cpp
+++ b/pacman-c++/server.cpp
@@ -9,6 +9,7 @@
9Server::Server(QWidget *parent) 9Server::Server(QWidget *parent)
10 : SceneHolder(parent) 10 : SceneHolder(parent)
11{ 11{
12
12 qDebug() << "waiting for clients"; 13 qDebug() << "waiting for clients";
13 waitForClientConnections(); 14 waitForClientConnections();
14 qDebug() << "clients connected"; 15 qDebug() << "clients connected";
@@ -193,6 +194,7 @@ void Server::keyPressUpdate()
193 } 194 }
194} 195}
195 196
197
196int main(int argc, char ** argv) 198int main(int argc, char ** argv)
197{ 199{
198 GOOGLE_PROTOBUF_VERIFY_VERSION; 200 GOOGLE_PROTOBUF_VERIFY_VERSION;
@@ -203,7 +205,7 @@ int main(int argc, char ** argv)
203 205
204 qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); 206 qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
205 207
208 Constants::server = true;
206 Server Server; 209 Server Server;
207
208 return app.exec(); 210 return app.exec();
209} 211}