summaryrefslogtreecommitdiffstats
path: root/pacman-c++
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2011-04-12 21:53:36 +0200
committermanuel <manuel@mausz.at>2011-04-12 21:53:36 +0200
commitc910e2267d3af30f10b9c659b2d9f9349c596e0d (patch)
treec6b531b4d70faa0d88b0f86e81180f30e99b3060 /pacman-c++
parentcfbd1b80e7e1f89861c96e6d802a3fe11df00929 (diff)
downloadfoop-c910e2267d3af30f10b9c659b2d9f9349c596e0d.tar.gz
foop-c910e2267d3af30f10b9c659b2d9f9349c596e0d.tar.bz2
foop-c910e2267d3af30f10b9c659b2d9f9349c596e0d.zip
remove animationmanager (for now?)
Diffstat (limited to 'pacman-c++')
-rw-r--r--pacman-c++/actor.cpp25
-rw-r--r--pacman-c++/animationmanager.cpp56
-rw-r--r--pacman-c++/animationmanager.h33
-rw-r--r--pacman-c++/pacman.pro2
-rw-r--r--pacman-c++/pacman.server.pro2
5 files changed, 3 insertions, 115 deletions
diff --git a/pacman-c++/actor.cpp b/pacman-c++/actor.cpp
index 7b77851..6ca981c 100644
--- a/pacman-c++/actor.cpp
+++ b/pacman-c++/actor.cpp
@@ -1,5 +1,4 @@
1#include "actor.h" 1#include "actor.h"
2#include "animationmanager.h"
3#include <QtCore/QPropertyAnimation> 2#include <QtCore/QPropertyAnimation>
4#include <QtCore/QVariantAnimation> 3#include <QtCore/QVariantAnimation>
5#include <QDebug> 4#include <QDebug>
@@ -122,7 +121,7 @@ void Actor::move(Actor::Movement direction)
122 if (Constants::server) 121 if (Constants::server)
123 return moveByServer(direction); 122 return moveByServer(direction);
124 123
125 /* stop current animation */ 124 /* stop current animation if direction changed */
126 if (direction != m_direction) 125 if (direction != m_direction)
127 { 126 {
128 /* hide all pictures */ 127 /* hide all pictures */
@@ -130,10 +129,7 @@ void Actor::move(Actor::Movement direction)
130 m_images.at(i)->setVisible(false); 129 m_images.at(i)->setVisible(false);
131 130
132 if (m_eating[m_direction] != NULL) 131 if (m_eating[m_direction] != NULL)
133 {
134 m_eating[m_direction]->stop(); 132 m_eating[m_direction]->stop();
135 //AnimationManager::self()->unregisterAnimation(m_eating[m_direction]);
136 }
137 } 133 }
138 134
139 QPointF endpos(0, 0); 135 QPointF endpos(0, 0);
@@ -165,7 +161,7 @@ void Actor::move(Actor::Movement direction)
165 } 161 }
166 setPos(pos() + endpos); 162 setPos(pos() + endpos);
167 163
168 /* start new animation */ 164 /* start new animation if direction changed */
169 if (direction != m_direction) 165 if (direction != m_direction)
170 { 166 {
171 if (direction == Actor::None) 167 if (direction == Actor::None)
@@ -174,24 +170,9 @@ void Actor::move(Actor::Movement direction)
174 m_eating[direction]->start(); 170 m_eating[direction]->start();
175 } 171 }
176 172
173 /* start moving animation */
177 if (direction != Actor::None) 174 if (direction != Actor::None)
178 {
179 //if (m_local && m_player->isWorking() && m_player->state() != Phonon::PlayingState)
180 // m_player->play();
181 m_moving->start(); 175 m_moving->start();
182 }
183 else if (direction != m_direction)
184 {
185 //if (m_local && m_player->isWorking() && m_player->state() != Phonon::PausedState)
186 // m_player->pause();
187 }
188
189 if (direction == Actor::None)
190 {
191 //TODO
192 qDebug() << "pause";
193 //m_wakaPlayer->pause();
194 }
195 176
196 m_direction = direction; 177 m_direction = direction;
197} 178}
diff --git a/pacman-c++/animationmanager.cpp b/pacman-c++/animationmanager.cpp
deleted file mode 100644
index 3880b08..0000000
--- a/pacman-c++/animationmanager.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
1#include "animationmanager.h"
2#include <QtCore/QAbstractAnimation>
3#include <QtCore/QDebug>
4
5// the universe's only animation manager
6AnimationManager *AnimationManager::instance = NULL;
7
8AnimationManager::AnimationManager()
9{
10}
11
12AnimationManager *AnimationManager::self()
13{
14 if (!instance)
15 instance = new AnimationManager;
16 return instance;
17}
18
19void AnimationManager::registerAnimation(QAbstractAnimation *anim)
20{
21 QObject::connect(anim, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterAnimation_helper(QObject*)));
22 animations.append(anim);
23}
24
25void AnimationManager::unregisterAnimation_helper(QObject *obj)
26{
27 unregisterAnimation(static_cast<QAbstractAnimation*>(obj));
28}
29
30void AnimationManager::unregisterAnimation(QAbstractAnimation *anim)
31{
32 QObject::disconnect(anim, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterAnimation_helper(QObject*)));
33 animations.removeAll(anim);
34}
35
36void AnimationManager::unregisterAllAnimations()
37{
38 animations.clear();
39}
40
41void AnimationManager::pauseAll()
42{
43 foreach (QAbstractAnimation* animation, animations)
44 {
45 if (animation->state() == QAbstractAnimation::Running)
46 animation->pause();
47 }
48}
49void AnimationManager::resumeAll()
50{
51 foreach (QAbstractAnimation* animation, animations)
52 {
53 if (animation->state() == QAbstractAnimation::Paused)
54 animation->resume();
55 }
56}
diff --git a/pacman-c++/animationmanager.h b/pacman-c++/animationmanager.h
deleted file mode 100644
index 408395b..0000000
--- a/pacman-c++/animationmanager.h
+++ /dev/null
@@ -1,33 +0,0 @@
1#ifndef ANIMATIONMANAGER_H
2#define ANIMATIONMANAGER_H
3
4#include <QtCore/QObject>
5
6QT_BEGIN_NAMESPACE
7class QAbstractAnimation;
8QT_END_NAMESPACE
9
10class AnimationManager
11 : public QObject
12{
13 Q_OBJECT
14public:
15 AnimationManager();
16 void registerAnimation(QAbstractAnimation *anim);
17 void unregisterAnimation(QAbstractAnimation *anim);
18 void unregisterAllAnimations();
19 static AnimationManager *self();
20
21public slots:
22 void pauseAll();
23 void resumeAll();
24
25private slots:
26 void unregisterAnimation_helper(QObject *obj);
27
28private:
29 static AnimationManager *instance;
30 QList<QAbstractAnimation *> animations;
31};
32
33#endif // ANIMATIONMANAGER_H
diff --git a/pacman-c++/pacman.pro b/pacman-c++/pacman.pro
index f8beb4a..b5492cd 100644
--- a/pacman-c++/pacman.pro
+++ b/pacman-c++/pacman.pro
@@ -5,7 +5,6 @@ VERSION = 0.1
5QT += phonon network 5QT += phonon network
6SOURCES += pixmapitem.cpp \ 6SOURCES += pixmapitem.cpp \
7 actor.cpp \ 7 actor.cpp \
8 animationmanager.cpp \
9 block.cpp \ 8 block.cpp \
10 client.cpp \ 9 client.cpp \
11 bonuspoint.cpp \ 10 bonuspoint.cpp \
@@ -18,7 +17,6 @@ SOURCES += pixmapitem.cpp \
18 gameentity.cpp 17 gameentity.cpp
19HEADERS += pixmapitem.h \ 18HEADERS += pixmapitem.h \
20 actor.h \ 19 actor.h \
21 animationmanager.h \
22 block.h \ 20 block.h \
23 client.h \ 21 client.h \
24 bonuspoint.h \ 22 bonuspoint.h \
diff --git a/pacman-c++/pacman.server.pro b/pacman-c++/pacman.server.pro
index 075f44d..2224d9a 100644
--- a/pacman-c++/pacman.server.pro
+++ b/pacman-c++/pacman.server.pro
@@ -8,7 +8,6 @@ TARGET = pacman-server
8QT += phonon network 8QT += phonon network
9SOURCES += pixmapitem.cpp \ 9SOURCES += pixmapitem.cpp \
10 actor.cpp \ 10 actor.cpp \
11 animationmanager.cpp \
12 block.cpp \ 11 block.cpp \
13 server.cpp \ 12 server.cpp \
14 bonuspoint.cpp \ 13 bonuspoint.cpp \
@@ -20,7 +19,6 @@ SOURCES += pixmapitem.cpp \
20 gameentity.cpp 19 gameentity.cpp
21HEADERS += pixmapitem.h \ 20HEADERS += pixmapitem.h \
22 actor.h \ 21 actor.h \
23 animationmanager.h \
24 block.h \ 22 block.h \
25 server.h \ 23 server.h \
26 bonuspoint.h \ 24 bonuspoint.h \