summaryrefslogtreecommitdiffstats
path: root/pacman-c++/mainwidget.cpp
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2011-04-09 01:01:03 +0200
committermanuel <manuel@mausz.at>2011-04-09 01:01:03 +0200
commit42322689a9fad5c2ca2e4d4c9bffcea2b08c02b5 (patch)
tree584b22d612fc47d920941cdcdc2c57e75d04c7c7 /pacman-c++/mainwidget.cpp
parent373af4019b134f8abad85d4da5e4c907fb6c64a8 (diff)
parentfe11a3bf19040388671a141a7282f375073cf67d (diff)
downloadfoop-42322689a9fad5c2ca2e4d4c9bffcea2b08c02b5.tar.gz
foop-42322689a9fad5c2ca2e4d4c9bffcea2b08c02b5.tar.bz2
foop-42322689a9fad5c2ca2e4d4c9bffcea2b08c02b5.zip
Merge branch 'master' of ssh://manuel.mausz.at/foop
Diffstat (limited to 'pacman-c++/mainwidget.cpp')
-rw-r--r--pacman-c++/mainwidget.cpp42
1 files changed, 40 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)