00001 #ifndef REFEREE_H
00002 #define REFEREE_H
00003
00004 #ifdef HAVE_CONFIG_H
00005 #include <config.h>
00006 #endif
00007
00008 #include "portable.h"
00009
00010 #if defined( KDE2_PORT )
00011 #include <kapp.h>
00012 #endif
00013
00014 #include <qwidget.h>
00015 #include <qlist.h>
00016 #include <qstrlist.h>
00017 #include <qarray.h>
00018 #include <qbitarry.h>
00019
00020 #include "board.h"
00021 #include "pacman.h"
00022 #include "monster.h"
00023 #include "fruit.h"
00024 #include "energizer.h"
00025 #include "bitfont.h"
00026 #include "painter.h"
00027
00028 enum { Init, Introducing, Playing, Demonstration, Paused, Player, Ready,
00029 Scoring, LevelDone, Dying, GameOver, HallOfFame };
00030
00031
00032 class Referee : public QWidget
00033 {
00034 Q_OBJECT
00035 public:
00036 Referee (QWidget *parent=0, const char *name=0, int scheme=-1, int mode=-1, Bitfont *font=0);
00037
00038 void setSkill(int);
00039 void setRoom(int);
00040
00041 public slots:
00042 void setScheme(int scheme, int mode, Bitfont *font=0);
00043
00044 void levelUp();
00045 void levelUpPlay();
00046
00047 void pause();
00048 void ready();
00049 void intro();
00050 void introPlay();
00051 void hallOfFame();
00052 void demo();
00053 void play();
00054 void killed();
00055 void killedPlay();
00056 void eaten();
00057 void toggleHallOfFame();
00058
00059 void setFocusOutPause(bool focusOutPause);
00060 void setFocusInContinue(bool focusInContinue);
00061 void initKeys();
00062
00063 void repaintFigures();
00064
00065 private slots:
00066 void start();
00067 void stop();
00068 void stopEnergizer();
00069
00070 signals:
00071 void setScore(int, int);
00072 void setPoints(int);
00073 void setLevel(int);
00074 void setLifes(int);
00075
00076 void toggleNew();
00077 void togglePaused();
00078 void forcedHallOfFame(bool);
00079
00080 protected:
00081 void timerEvent(QTimerEvent *);
00082 void paintEvent(QPaintEvent *);
00083 void keyPressEvent(QKeyEvent *);
00084
00085 void focusOutEvent(QFocusEvent *);
00086 void focusInEvent(QFocusEvent *);
00087
00088 void fillArray(QArray<int> &, QString, int);
00089 void fillStrList(QStrList &, QString, int);
00090 void fillMapName();
00091
00092 void confScheme();
00093 void confLevels(bool defGroup=TRUE);
00094 void confMisc(bool defGroup=TRUE);
00095 void confTiming(bool defGroup=TRUE);
00096 void confScoring(bool defGroup=TRUE);
00097
00098 private:
00099 QBitArray gameState;
00100 int timerCount;
00101 int maxLevel;
00102
00103 int scheme;
00104 int mode;
00105
00106 QString pixmapDirectory;
00107 QString mapDirectory;
00108 QStrList mapName;
00109
00110 QArray<int> speed;
00111 QArray<int> monsterIQ;
00112 QArray<int> fruitIQ;
00113 QArray<int> fruitIndex;
00114 QArray<int> pacmanTicks;
00115 QArray<int> remTicks;
00116 QArray<int> dangerousTicks;
00117 QArray<int> harmlessTicks;
00118 QArray<int> harmlessDurTicks;
00119 QArray<int> harmlessWarnTicks;
00120 QArray<int> arrestTicks;
00121 QArray<int> arrestDurTicks;
00122 QArray<int> fruitTicks;
00123 QArray<int> fruitAppearsTicks;
00124 QArray<int> fruitDurTicks;
00125 QArray<int> fruitScoreDurTicks;
00126
00127 int monsterScoreDurMS;
00128 int playerDurMS;
00129 int readyDurMS;
00130 int gameOverDurMS;
00131 int afterPauseMS;
00132 int dyingPreAnimationMS;
00133 int dyingAnimationMS;
00134 int dyingPostAnimationMS;
00135 int introAnimationMS;
00136 int introPostAnimationMS;
00137 int levelUpPreAnimationMS;
00138 int levelUpAnimationMS;
00139 int energizerAnimationMS;
00140
00141 int pointScore;
00142 int energizerScore;
00143 QArray<int> fruitScore;
00144 QArray<int> monsterScore;
00145 QArray<int> extraLifeScore;
00146
00147 int extraLifeScoreIndex;
00148 int nextExtraLifeScore;
00149
00150 int monstersEaten;
00151 int points;
00152 int lifes;
00153 int level;
00154
00155 bool focusedPause;
00156 bool focusOutPause;
00157 bool focusInContinue;
00158
00159 Board *board;
00160 Painter *pix;
00161 Pacman *pacman;
00162 Fruit *fruit;
00163
00164 QList<Monster> *monsters;
00165 QList<QRect> *monsterRect;
00166
00167 QList<Energizer> *energizers;
00168 QList<QRect> *energizerRect;
00169
00170 QRect pacmanRect;
00171 QRect fruitRect;
00172
00173 void introMonster(int id);
00174 void introPaint(int t);
00175
00176 void initMonsters();
00177 void initPacman();
00178 void initFruit(bool fullInitialization=TRUE);
00179 void initEnergizers();
00180
00181 void setOnEnergizers();
00182
00183 int gameTimer;
00184 int energizerTimer;
00185 void start(int);
00186 void init(bool);
00187
00188 void score(int);
00189
00190 uint UpKey;
00191 uint DownKey;
00192 uint RightKey;
00193 uint LeftKey;
00194 };
00195
00196 #endif // REFEREE_H