Diffstat (limited to 'noncore/games/kpacman/board.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/kpacman/board.h | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/noncore/games/kpacman/board.h b/noncore/games/kpacman/board.h new file mode 100644 index 0000000..fffde95 --- a/dev/null +++ b/noncore/games/kpacman/board.h | |||
@@ -0,0 +1,102 @@ | |||
1 | #ifndef BOARD_H | ||
2 | #define BOARD_H | ||
3 | |||
4 | #include <qarray.h> | ||
5 | #include <qstring.h> | ||
6 | #include <qlist.h> | ||
7 | #include <qrect.h> | ||
8 | |||
9 | #define OUT -1 | ||
10 | |||
11 | enum Square {out = OUT, empty, brick, prison, gate, tunnel, prisonentry, prisonexit, | ||
12 | Point, energizer, fruit, pacman, monster, | ||
13 | fruithome, pacmanhome, monsterhome}; | ||
14 | |||
15 | enum Image { None, Intro, Demo, Level, File }; | ||
16 | |||
17 | #define X -1 | ||
18 | #define N 0 | ||
19 | #define S 1 | ||
20 | #define E 2 | ||
21 | #define W 3 | ||
22 | #define NE 4 | ||
23 | #define SE 5 | ||
24 | #define NW 6 | ||
25 | #define SW 7 | ||
26 | |||
27 | #define BoardWidth 59 | ||
28 | #define BoardHeight 65 | ||
29 | |||
30 | #define fixBits 0x0007 | ||
31 | #define varBits 0xFFF8 | ||
32 | #define monsterBits 0xFF00 | ||
33 | |||
34 | #define pointBit 0x0008 | ||
35 | #define energizerBit 0x0010 | ||
36 | #define fruitBit 0x0020 | ||
37 | #define pacmanBit 0x0040 | ||
38 | #define monsterBit 0x0100 | ||
39 | |||
40 | class Board : public QArray<int> | ||
41 | { | ||
42 | public: | ||
43 | Board (int size); | ||
44 | ~Board() {}; | ||
45 | void init(Image image, QString levelName=0); | ||
46 | void setup(const uchar *buf); | ||
47 | |||
48 | void set(int pos, Square sq, int m = 0); | ||
49 | void reset(int pos, Square sq, int m = 0); | ||
50 | int position(Square sq, int m = 0); | ||
51 | |||
52 | bool isOut(int pos); | ||
53 | bool isEmpty(int pos); | ||
54 | bool isBrick(int pos); | ||
55 | bool isPrison(int pos); | ||
56 | bool isGate(int pos); | ||
57 | bool isTunnel(int pos); | ||
58 | bool isPoint(int pos); | ||
59 | bool isEnergizer(int pos); | ||
60 | bool isFruit(int pos); | ||
61 | bool isPacman(int pos); | ||
62 | bool isMonster(int pos); | ||
63 | bool isWay(int pos, int dir, Square sq); | ||
64 | bool isJump(int pos, int dir); | ||
65 | |||
66 | int move(int pos, int dir, int steps = 1); | ||
67 | int closeup(int pos, int dir, int target); | ||
68 | int x(int pos); | ||
69 | int y(int pos); | ||
70 | int turn(int dir); | ||
71 | |||
72 | int points(); | ||
73 | int energizers(); | ||
74 | int monsters(); | ||
75 | int tunnels(); | ||
76 | |||
77 | private: | ||
78 | bool inBounds(int pos); | ||
79 | int sz; // size of board | ||
80 | |||
81 | QString map; | ||
82 | QString mapName; // Filename of the latest loaded map | ||
83 | |||
84 | int prisonEntry; // position of prisonentry | ||
85 | int prisonExit; // position of prisonexit | ||
86 | int pacmanHome; // startposition of pacman | ||
87 | int monsterHome[8]; // startposition of monsters | ||
88 | int fruitHome; // startposition of fruit | ||
89 | |||
90 | int pacmanPosition; // actual position of pacman | ||
91 | int monsterPosition[8]; // actual position of monsters | ||
92 | int fruitPosition; // actual position of fruit | ||
93 | int energizerPosition[8]; // actual position of energizers | ||
94 | int tunnelPosition[8]; // position of tunnels | ||
95 | |||
96 | int numMonsters; // number of monsters on the board | ||
97 | int numPoints; // number of points (left) on the board | ||
98 | int numEnergizers; // number of energizers (left) | ||
99 | int numTunnels; // number of tunnels on the board | ||
100 | }; | ||
101 | |||
102 | #endif // BOARD_H | ||