summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/kpacman/referee.cpp18
1 files changed, 2 insertions, 16 deletions
diff --git a/noncore/games/kpacman/referee.cpp b/noncore/games/kpacman/referee.cpp
index 81f331b..6d8f3fb 100644
--- a/noncore/games/kpacman/referee.cpp
+++ b/noncore/games/kpacman/referee.cpp
@@ -633,209 +633,195 @@ void Referee::confScheme()
APP_CONFIG_BEGIN( cfg );
SAVE_CONFIG_GROUP( cfg, oldgroup );
QString newgroup;
// if not set, read mode and scheme from the configfile
if (mode == -1 && scheme == -1) {
scheme = cfg->readNumEntry("Scheme", -1);
mode = cfg->readNumEntry("Mode", -1);
// if mode is not set in the defGroup-group, lookup the scheme group
if (scheme != -1 || mode == -1) {
newgroup.sprintf("Scheme %d", scheme);
cfg->setGroup(newgroup);
mode = cfg->readNumEntry("Mode", -1);
RESTORE_CONFIG_GROUP( cfg, oldgroup );
}
}
confLevels();
if (mode != -1) {
newgroup.sprintf("Mode %d", mode);
cfg->setGroup(newgroup);
confLevels(FALSE);
}
if (scheme != -1) {
newgroup.sprintf("Scheme %d", scheme);
cfg->setGroup(newgroup);
confLevels(FALSE);
}
RESTORE_CONFIG_GROUP( cfg, oldgroup );
confMisc();
confTiming();
confScoring();
if (mode != -1) {
newgroup.sprintf("Mode %d", mode);
cfg->setGroup(newgroup);
confMisc(FALSE);
confTiming(FALSE);
confScoring(FALSE);
}
if (scheme != -1) {
newgroup.sprintf("Scheme %d", scheme);
cfg->setGroup(newgroup);
confMisc(FALSE);
confTiming(FALSE);
confScoring(FALSE);
}
fillMapName();
RESTORE_CONFIG_GROUP( cfg, oldgroup );
APP_CONFIG_END( cfg );
}
void Referee::setScheme(int Scheme, int Mode, Bitfont *font)
{
mode = Mode;
scheme = Scheme;
confScheme();
pix->setScheme(scheme, mode, font);
pacman->setMaxPixmaps(pix->maxPixmaps(PacmanPix));
fruit->setMaxPixmaps(pix->maxPixmaps(FruitPix));
for (Monster *m = monsters->first(); m != 0; m = monsters->next())
if (m)
m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix));
for (Energizer *e = energizers->first(); e != 0; e = energizers->next())
if (e)
e->setMaxPixmaps(pix->maxPixmaps(EnergizerPix));
if (gameState.testBit(Introducing))
for (int i = 0; i < (gameState.testBit(Init) ? timerCount : 15); i++)
introPaint(i);
setFixedSize(pix->levelPix().size());
repaint();
}
void Referee::keyPressEvent( QKeyEvent *k )
{
uint key = k->key();
-#ifdef QWS
- // "OK" => new game
- if ( key == Key_F33 || key == Key_F2 || key == Key_Enter )
- play();
- else if ( !gameState.testBit(Playing) &&
- ( key == Key_Up ||
- key == Key_Down ||
- key == Key_Right ||
- key == Key_Left ))
+
+ if ( !gameState.testBit(Playing) && ( key == Key_Up || key == Key_Down || key == Key_Left || key == Key_Right ) )
play();
- // "Space" => pause
- //else if ( key == Key_Space || key == Key_F3 )
- // pause();
- // "Menu" => hall of fame
- //else if ( key == Key_F11 || key == Key_F4 )
- // toggleHallOfFame();
-#endif
if (gameState.testBit(Paused) || gameState.testBit(HallOfFame) ||
gameState.testBit(Demonstration) || gameState.testBit(Dying) ||
gameState.testBit(Ready) || gameState.testBit(LevelDone) ||
!gameState.testBit(Playing))
return;
if (key == UpKey)
pacman->setDirection(N);
else if (key == DownKey)
pacman->setDirection(S);
else if (key == RightKey)
pacman->setDirection(E);
else if (key == LeftKey)
pacman->setDirection(W);
#ifdef CHEATS
else if (key == Key_L) { printf("levelUp()\n"); levelUp(); }
else if (key == Key_F) { printf("fruit->move(TRUE)\n"); fruit->move(TRUE); repaint(FALSE); }
else if (key == Key_E) { printf("setLifes(++lifes)\n"); emit setLifes(++lifes); }
#endif
else {
k->ignore();
return;
}
k->accept();
}
void Referee::score(int p)
{
if (!gameState.testBit(Playing))
return;
if ((points += p) < 0)
points = 0;
emit setPoints(points);
if (points >= nextExtraLifeScore) {
emit setLifes(++lifes);
if (extraLifeScoreIndex < (int) extraLifeScore.size()-1)
extraLifeScoreIndex++;
if (extraLifeScore[extraLifeScoreIndex] < 0)
nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex] * -1;
else
nextExtraLifeScore += extraLifeScore[extraLifeScoreIndex];
}
}
void Referee::eaten()
{
if (gameState.testBit(Ready))
return;
stop();
if (monstersEaten < 4)
monstersEaten++;
gameState.setBit(Scoring);
score(monsterScore[monstersEaten-1]);
repaint(pix->rect(pix->rect(pacman->position(), MonsterPix),
pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1)));
if (--timerCount > 0)
QTimer::singleShot( monsterScoreDurMS, this, SLOT(eaten()));
else {
for (Monster *m = monsters->first(); m != 0; m = monsters->next())
if (m && m->direction() == X && !gameState.testBit(Introducing))
m->setDirection(N);
if (monstersEaten != 4 || !gameState.testBit(Introducing))
QTimer::singleShot( monsterScoreDurMS, this, SLOT(start()));
}
}
void Referee::toggleHallOfFame()
{
gameState.toggleBit(HallOfFame);
}
void Referee::hallOfFame()
{
if (gameState.testBit(HallOfFame)) // If the HallOfFame is switched on manually, toggle the
toggleHallOfFame(); // bit twice.
emit setLevel(0); // Clear status display for hall of fame
emit setScore(level, 0);
emit forcedHallOfFame(TRUE);
}
void Referee::pause()
{
static int pausedTimer = 0;