diff options
| author | manuel <manuel@mausz.at> | 2011-04-09 01:01:03 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2011-04-09 01:01:03 +0200 |
| commit | 42322689a9fad5c2ca2e4d4c9bffcea2b08c02b5 (patch) | |
| tree | 584b22d612fc47d920941cdcdc2c57e75d04c7c7 /pacman-c++ | |
| parent | 373af4019b134f8abad85d4da5e4c907fb6c64a8 (diff) | |
| parent | fe11a3bf19040388671a141a7282f375073cf67d (diff) | |
| download | foop-42322689a9fad5c2ca2e4d4c9bffcea2b08c02b5.tar.gz foop-42322689a9fad5c2ca2e4d4c9bffcea2b08c02b5.tar.bz2 foop-42322689a9fad5c2ca2e4d4c9bffcea2b08c02b5.zip | |
Merge branch 'master' of ssh://manuel.mausz.at/foop
Diffstat (limited to 'pacman-c++')
| -rw-r--r-- | pacman-c++/mainwidget.cpp | 42 | ||||
| -rw-r--r-- | pacman-c++/mainwidget.h | 1 |
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 | ||
| 99 | void MainWidget::createGui() | 105 | void MainWidget::createGui() |
| @@ -286,6 +292,36 @@ Transmission::field_t MainWidget::translateKey(int key) | |||
| 286 | } | 292 | } |
| 287 | } | 293 | } |
| 288 | 294 | ||
| 295 | void 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 | |||
| 289 | void MainWidget::keyPressEvent(QKeyEvent* event) | 325 | void 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: | |||
| 31 | private slots: | 31 | private slots: |
| 32 | void startGame(); | 32 | void startGame(); |
| 33 | void playerScoreClicked(); | 33 | void playerScoreClicked(); |
| 34 | void tick(); | ||
| 34 | 35 | ||
| 35 | private: | 36 | private: |
| 36 | QVector< QVector<PixmapItem *> > visualMap; | 37 | QVector< QVector<PixmapItem *> > visualMap; |
