void checkCollision(void) { for(int i = 0; i < 4; i++) { //collision when they are on the same node if (Man.cur == Ghosts[i].cur) returnToMenu(-1); //collision when pacman is moving to the ghosts node if (Man.xMov > 0) { if (Man.cur->nbor.right == Ghosts[i].cur) returnToMenu(-1); } else if (Man.xMov < 0) { if (Man.cur->nbor.left == Ghosts[i].cur) returnToMenu(-1); } else if (Man.yMov < 0) { if (Man.cur->nbor.down == Ghosts[i].cur) returnToMenu(-1); } else if (Man.yMov > 0) { if (Man.cur->nbor.up == Ghosts[i].cur) returnToMenu(-1); } } }
void GameScreen::createActions() { quit = new QAction("Main Menu", this); connect(quit, SIGNAL(triggered()), this, SLOT(returnToMenu())); save = new QAction("Save and Quit", this); connect(save, SIGNAL(triggered()), dynamic_cast<startup*>(this->parent()), SLOT(saveGame())); }
void GameView::keyPressEvent(QKeyEvent *e) { switch (e->key()) { case Qt::Key_Escape: emit returnToMenu(); break; default: am.actionChanged(NO_ACTION); ressUi->shortCutPressed(e); powerUi->shortCutPressed(e); break; } }
/* adding scores if pacman hits a dot or ppill */ void addScores(void) { if (Man.cur->dot > 0) { // add score score = score + dotScore; Man.cur->dot = 0; // decrease the number of dots numDots--; } if (Man.cur->ppill > 0) { // add score score = score + ppillScore; Man.cur->ppill = 0; numDots--; } // check if the game ended if (numDots < 1) { returnToMenu(1); } }