summaryrefslogtreecommitdiffstats
path: root/kpacman/referee.h
blob: 376b5c27325f0546dd0dd56a2bd8a9be02cb00b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#ifndef REFEREE_H               
#define REFEREE_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <kapp.h>
#include <qwidget.h>
#include <qlist.h>
#include <qstrlist.h>
#include <qarray.h>
#include <qbitarry.h>

#include "board.h"
#include "pacman.h"
#include "monster.h"
#include "fruit.h"
#include "energizer.h"
#include "bitfont.h"
#include "painter.h"

enum { Init, Introducing, Playing, Demonstration, Paused, Player, Ready, 
       Scoring, LevelDone, Dying, GameOver, HallOfFame };


class Referee : public QWidget
{
    Q_OBJECT
public:
    Referee (QWidget *parent=0, const char *name=0, int scheme=-1, int mode=-1, Bitfont *font=0);

    void setSkill(int);
    void setRoom(int);

public slots:
    void setScheme(int scheme, int mode, Bitfont *font=0);

    void levelUp();
    void levelUpPlay();

    void pause();
    void ready();
    void intro();
    void introPlay();
    void hallOfFame();
    void demo();
    void play();
    void killed();
    void killedPlay();
    void eaten();
    void toggleHallOfFame();

    void setFocusOutPause(bool focusOutPause);
    void setFocusInContinue(bool focusInContinue);
    void initKeys();

    void repaintFigures();

private slots:
    void start();
    void stop();
    void stopEnergizer();

signals:
    void setScore(int, int);
    void setPoints(int);
    void setLevel(int);
    void setLifes(int);

    void focusedGamePause();
    void forcedGameHighscores();

protected:
    void timerEvent(QTimerEvent *);
    void paintEvent(QPaintEvent *);
    void keyPressEvent(QKeyEvent *);

    void focusOutEvent(QFocusEvent *);
    void focusInEvent(QFocusEvent *);

    void fillArray(QArray<int> &, QString, int);
    void fillStrList(QStrList &, QString, int);
    void fillMapName();

    void confScheme();
    void confLevels(bool defGroup=TRUE);
    void confMisc(bool defGroup=TRUE);
    void confTiming(bool defGroup=TRUE);
    void confScoring(bool defGroup=TRUE);

private:
    QBitArray gameState;
    int timerCount;
    int maxLevel;

    int scheme;
    int mode;

    QString pixmapDirectory;
    QString mapDirectory;
    QStrList mapName;

    QArray<int> speed;
    QArray<int> monsterIQ;
    QArray<int> fruitIQ;
    QArray<int> fruitIndex;
    QArray<int> pacmanTicks;
    QArray<int> remTicks;
    QArray<int> dangerousTicks;
    QArray<int> harmlessTicks;
    QArray<int> harmlessDurTicks;
    QArray<int> harmlessWarnTicks;
    QArray<int> arrestTicks;
    QArray<int> arrestDurTicks;
    QArray<int> fruitTicks;
    QArray<int> fruitAppearsTicks;
    QArray<int> fruitDurTicks;
    QArray<int> fruitScoreDurTicks;

    int monsterScoreDurMS;
    int playerDurMS;
    int readyDurMS;
    int gameOverDurMS;
    int afterPauseMS;
    int dyingPreAnimationMS;
    int dyingAnimationMS;
    int dyingPostAnimationMS;
    int introAnimationMS;
    int introPostAnimationMS;
    int levelUpPreAnimationMS;
    int levelUpAnimationMS;
    int energizerAnimationMS;

    int pointScore;
    int energizerScore;
    QArray<int> fruitScore;
    QArray<int> monsterScore;
    QArray<int> extraLifeScore;

    int extraLifeScoreIndex;
    int nextExtraLifeScore;

    int monstersEaten;
    int points;
    int lifes;
    int level;

    bool focusedPause;
    bool focusOutPause;
    bool focusInContinue;

    Board   *board;
    Painter *pix;
    Pacman  *pacman;
    Fruit   *fruit;

    QList<Monster> *monsters;
    QList<QRect> *monsterRect;

    QList<Energizer> *energizers;
    QList<QRect> *energizerRect;

    QRect pacmanRect;
    QRect fruitRect;

    void introMonster(int id);
    void introPaint(int t);

    void initMonsters();
    void initPacman();
    void initFruit(bool fullInitialization=TRUE);
    void initEnergizers();

    void setOnEnergizers();

    int  gameTimer;
    int  energizerTimer;
    void start(int);
    void init(bool);

    void score(int);

    uint UpKey;
    uint DownKey;
    uint RightKey;
    uint LeftKey;
};

#endif // REFEREE_H