summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortotycro <totycro@unknown-horizons.org>2011-04-09 00:55:05 +0200
committertotycro <totycro@unknown-horizons.org>2011-04-09 00:55:05 +0200
commitfe11a3bf19040388671a141a7282f375073cf67d (patch)
tree52f4bcad87767788e40ab38c3aaf55a88de2244e
parent354d090ce32c074b7069ed29fa1adde2c30ea72e (diff)
downloadfoop-fe11a3bf19040388671a141a7282f375073cf67d.tar.gz
foop-fe11a3bf19040388671a141a7282f375073cf67d.tar.bz2
foop-fe11a3bf19040388671a141a7282f375073cf67d.zip
tried to make movement more smooth
-rw-r--r--pacman-c++/mainwidget.cpp42
-rw-r--r--pacman-c++/mainwidget.h1
2 files changed, 41 insertions, 2 deletions
diff --git a/pacman-c++/mainwidget.cpp b/pacman-c++/mainwidget.cpp
index b421c36..072d417 100644
--- a/pacman-c++/mainwidget.cpp
+++ b/pacman-c++/mainwidget.cpp
@@ -92,8 +92,14 @@ MainWidget::MainWidget()
92 createGui(); 92 createGui();
93 updateMap(createDummyMap()); 93 updateMap(createDummyMap());
94 94
95 connect(AudioPlayer::self(), SIGNAL(finished()), this, SLOT(startGame())); 95 //connect(AudioPlayer::self(), SIGNAL(finished()), this, SLOT(startGame()));
96 AudioPlayer::self()->play(AudioPlayer::Intro); 96 //AudioPlayer::self()->play(AudioPlayer::Intro);
97
98 QTimer *timer = new QTimer(this);
99 connect(timer, SIGNAL(timeout()), this, SLOT(tick()));
100 timer->start(100);
101
102 startGame();
97} 103}
98 104
99void MainWidget::createGui() 105void MainWidget::createGui()
@@ -286,6 +292,36 @@ Transmission::field_t MainWidget::translateKey(int key)
286 } 292 }
287} 293}
288 294
295void MainWidget::tick()
296{
297 Actor::Movement mov = Actor::None;
298 switch(m_currentKey)
299 {
300 case Transmission::direction_up:
301 mov = Actor::Up;
302 break;
303 case Transmission::direction_down:
304 mov = Actor::Down;
305 break;
306 case Transmission::direction_left:
307 mov = Actor::Left;
308 break;
309 case Transmission::direction_right:
310 mov = Actor::Right;
311 break;
312 default:
313 break;
314 }
315
316 QMapIterator<Color::Color, Actor*> i(m_actors);
317 while (i.hasNext())
318 {
319 i.next();
320 i.value()->move(mov);
321 }
322}
323
324
289void MainWidget::keyPressEvent(QKeyEvent* event) 325void MainWidget::keyPressEvent(QKeyEvent* event)
290{ 326{
291 if (!m_running) 327 if (!m_running)
@@ -294,6 +330,8 @@ void MainWidget::keyPressEvent(QKeyEvent* event)
294 QWidget::keyPressEvent(event); 330 QWidget::keyPressEvent(event);
295 m_currentKey = translateKey(event->key()); 331 m_currentKey = translateKey(event->key());
296 332
333 return;
334
297 // test stuff 335 // test stuff
298 Actor::Movement mov = Actor::None; 336 Actor::Movement mov = Actor::None;
299 switch(m_currentKey) 337 switch(m_currentKey)
diff --git a/pacman-c++/mainwidget.h b/pacman-c++/mainwidget.h
index 8d21649..e7d146f 100644
--- a/pacman-c++/mainwidget.h
+++ b/pacman-c++/mainwidget.h
@@ -31,6 +31,7 @@ private:
31private slots: 31private slots:
32 void startGame(); 32 void startGame();
33 void playerScoreClicked(); 33 void playerScoreClicked();
34 void tick();
34 35
35private: 36private:
36 QVector< QVector<PixmapItem *> > visualMap; 37 QVector< QVector<PixmapItem *> > visualMap;