-rw-r--r-- | noncore/games/zbounce/game.h | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/noncore/games/zbounce/game.h b/noncore/games/zbounce/game.h index ae0d4fa..656fba3 100644 --- a/noncore/games/zbounce/game.h +++ b/noncore/games/zbounce/game.h | |||
@@ -1,183 +1,181 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de> | 2 | * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de> |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or | 4 | * This program is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library General Public | 5 | * modify it under the terms of the GNU Library General Public |
6 | * License as published by the Free Software Foundation; either | 6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. | 7 | * version 2 of the License, or (at your option) any later version. |
8 | * | 8 | * |
9 | * This program is distributed in the hope that it will be useful, | 9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Library General Public License for more details. | 12 | * Library General Public License for more details. |
13 | * | 13 | * |
14 | * You should have received a copy of the GNU Library General Public | 14 | * You should have received a copy of the GNU Library General Public |
15 | * License along with this program; if not, write to the Free | 15 | * License along with this program; if not, write to the Free |
16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #ifndef GAME_H_INCLUDED | 19 | #ifndef GAME_H_INCLUDED |
20 | #define GAME_H_INCLUDED | 20 | #define GAME_H_INCLUDED |
21 | 21 | ||
22 | #include <qwidget.h> | 22 | #include <qwidget.h> |
23 | #include <qcanvas.h> | 23 | #include <qcanvas.h> |
24 | #include <qmemarray.h> | ||
25 | 24 | ||
26 | class QTimer; | 25 | class QTimer; |
27 | class JezzField; | 26 | class JezzField; |
28 | 27 | ||
29 | #define FIELD_WIDTH 26 | 28 | #define FIELD_WIDTH 26 |
30 | #define FIELD_HEIGHT 26 | 29 | #define FIELD_HEIGHT 26 |
31 | 30 | ||
32 | class Arrow : public QCanvasSprite | 31 | class Arrow : public QCanvasSprite |
33 | { | 32 | { |
34 | public: | 33 | public: |
35 | Arrow(QCanvasPixmapArray* array, QCanvas* canvas); | 34 | Arrow(QCanvasPixmapArray* array, QCanvas* canvas); |
36 | 35 | ||
37 | void update(); | 36 | void update(); |
38 | void changeDirection(); | 37 | void changeDirection(); |
39 | 38 | ||
40 | protected: | 39 | protected: |
41 | bool m_vertical; | 40 | bool m_vertical; |
42 | }; | 41 | }; |
43 | 42 | ||
44 | class Ball : public QCanvasSprite | 43 | class Ball : public QCanvasSprite |
45 | { | 44 | { |
46 | public: | 45 | public: |
47 | Ball(QCanvasPixmapArray* array, QCanvas* canvas); | 46 | Ball(QCanvasPixmapArray* array, QCanvas* canvas); |
48 | 47 | ||
49 | void update(); | 48 | void update(); |
50 | void advance(int stage); | 49 | void advance(int stage); |
51 | bool collide( double dx=0, double dy=0 ); | 50 | bool collide( double dx=0, double dy=0 ); |
52 | 51 | ||
53 | protected: | 52 | protected: |
54 | int m_animDelay; | 53 | int m_animDelay; |
55 | int m_soundDelay; | 54 | int m_soundDelay; |
56 | }; | 55 | }; |
57 | 56 | ||
58 | 57 | ||
59 | class Wall : public QObject | 58 | class Wall : public QObject |
60 | { | 59 | { |
61 | Q_OBJECT | 60 | Q_OBJECT |
62 | public: | 61 | public: |
63 | enum Direction { Up, Down, Left, Right }; | 62 | enum Direction { Up, Down, Left, Right }; |
64 | 63 | ||
65 | Wall( JezzField *field, int x, int y, Direction dir, int tile, | 64 | Wall( JezzField *field, int x, int y, Direction dir, int tile, |
66 | QObject *parent=0, const char *name=0 ); | 65 | QObject *parent=0, const char *name=0 ); |
67 | 66 | ||
68 | void finish(); | 67 | void finish(); |
69 | void fill( bool black ); | 68 | void fill( bool black ); |
70 | 69 | ||
71 | signals: | 70 | signals: |
72 | void finished( Wall *wall, int tile ); | 71 | void finished( Wall *wall, int tile ); |
73 | 72 | ||
74 | public slots: | 73 | public slots: |
75 | void advance(); | 74 | void advance(); |
76 | void update(); | 75 | void update(); |
77 | 76 | ||
78 | private: | 77 | private: |
79 | bool isFree( int x, int y ); | 78 | bool isFree( int x, int y ); |
80 | 79 | ||
81 | Direction m_dir; | 80 | Direction m_dir; |
82 | JezzField *m_field; | 81 | JezzField *m_field; |
83 | int m_dx, m_dy; | 82 | int m_dx, m_dy; |
84 | int m_x, m_y; | 83 | int m_x, m_y; |
85 | int m_startX, m_startY; | 84 | int m_startX, m_startY; |
86 | int m_tile; | 85 | int m_tile; |
87 | int m_delay; | 86 | int m_delay; |
88 | bool m_active; | 87 | bool m_active; |
89 | }; | 88 | }; |
90 | 89 | ||
91 | 90 | ||
92 | class JezzField : public QCanvas | 91 | class JezzField : public QCanvas |
93 | { | 92 | { |
94 | Q_OBJECT | 93 | Q_OBJECT |
95 | public: | 94 | public: |
96 | JezzField( QPixmap tiles, QObject* parent = 0, const char* name = 0 ); | 95 | JezzField( QPixmap tiles, QObject* parent = 0, const char* name = 0 ); |
97 | 96 | ||
98 | void setGameTile( int x, int y, bool black ); | 97 | void setGameTile( int x, int y, bool black ); |
99 | 98 | ||
100 | signals: | 99 | signals: |
101 | void ballCollision( Ball *ball, int x, int y, int tile ); | 100 | void ballCollision( Ball *ball, int x, int y, int tile ); |
102 | 101 | ||
103 | private: | 102 | private: |
104 | friend class Ball; | 103 | friend class Ball; |
105 | QPixmap m_tiles; | 104 | QPixmap m_tiles; |
106 | QMemArray<QPixmap> m_backTiles; | ||
107 | 105 | ||
108 | void setPixmaps( QPixmap tiles ); | 106 | void setPixmaps( QPixmap tiles ); |
109 | void emitBallCollisiton( Ball *ball, int x, int y, int tile ) | 107 | void emitBallCollisiton( Ball *ball, int x, int y, int tile ) |
110 | { emit ballCollision( ball, x, y, tile ); }; | 108 | { emit ballCollision( ball, x, y, tile ); }; |
111 | 109 | ||
112 | }; | 110 | }; |
113 | 111 | ||
114 | 112 | ||
115 | class JezzView : public QCanvasView | 113 | class JezzView : public QCanvasView |
116 | { | 114 | { |
117 | Q_OBJECT | 115 | Q_OBJECT |
118 | public: | 116 | public: |
119 | JezzView(QCanvas* viewing=0, QWidget* parent=0, const char* name=0, WFlags f=0); | 117 | JezzView(QCanvas* viewing=0, QWidget* parent=0, const char* name=0, WFlags f=0); |
120 | void changeCursor(); | 118 | void changeCursor(); |
121 | 119 | ||
122 | signals: | 120 | signals: |
123 | void buildWall( int x, int y, bool vertical ); | 121 | void buildWall( int x, int y, bool vertical ); |
124 | 122 | ||
125 | protected: | 123 | protected: |
126 | void viewportMouseReleaseEvent( QMouseEvent * ); | 124 | void viewportMouseReleaseEvent( QMouseEvent * ); |
127 | 125 | ||
128 | private: | 126 | private: |
129 | bool m_vertical; | 127 | bool m_vertical; |
130 | }; | 128 | }; |
131 | 129 | ||
132 | 130 | ||
133 | class JezzGame : public QWidget | 131 | class JezzGame : public QWidget |
134 | { | 132 | { |
135 | Q_OBJECT | 133 | Q_OBJECT |
136 | 134 | ||
137 | public: | 135 | public: |
138 | JezzGame( int ballNum, QWidget *parent=0, const char *name=0 ); | 136 | JezzGame( int ballNum, QWidget *parent=0, const char *name=0 ); |
139 | ~JezzGame(); | 137 | ~JezzGame(); |
140 | 138 | ||
141 | int percent(); | 139 | int percent(); |
142 | void display( QString text, int size=20 ); | 140 | void display( QString text, int size=20 ); |
143 | void changeCursor(); | 141 | void changeCursor(); |
144 | 142 | ||
145 | signals: | 143 | signals: |
146 | void died(); | 144 | void died(); |
147 | void newPercent( int percent ); | 145 | void newPercent( int percent ); |
148 | 146 | ||
149 | public slots: | 147 | public slots: |
150 | void start(); | 148 | void start(); |
151 | void stop(); | 149 | void stop(); |
152 | 150 | ||
153 | protected slots: | 151 | protected slots: |
154 | void tick(); | 152 | void tick(); |
155 | void buildWall( int x, int y, bool vertical ); | 153 | void buildWall( int x, int y, bool vertical ); |
156 | void wallFinished( Wall *wall, int tile ); | 154 | void wallFinished( Wall *wall, int tile ); |
157 | void ballCollision( Ball *ball, int x, int y, int tile ); | 155 | void ballCollision( Ball *ball, int x, int y, int tile ); |
158 | 156 | ||
159 | protected: | 157 | protected: |
160 | void makeBlack(); | 158 | void makeBlack(); |
161 | void fill( int x, int y ); | 159 | void fill( int x, int y ); |
162 | void fillLeft( int x, int y ); | 160 | void fillLeft( int x, int y ); |
163 | int m_buf[FIELD_WIDTH][FIELD_HEIGHT]; | 161 | int m_buf[FIELD_WIDTH][FIELD_HEIGHT]; |
164 | 162 | ||
165 | JezzField *m_field; | 163 | JezzField *m_field; |
166 | JezzView *m_view; | 164 | JezzView *m_view; |
167 | 165 | ||
168 | Wall *m_wall1, *m_wall2; | 166 | Wall *m_wall1, *m_wall2; |
169 | 167 | ||
170 | QList<Ball> m_balls; | 168 | QList<Ball> m_balls; |
171 | QCanvasPixmapArray *m_ballPixmaps; | 169 | QCanvasPixmapArray *m_ballPixmaps; |
172 | QCanvasPixmapArray *m_arrowPixmaps; | 170 | QCanvasPixmapArray *m_arrowPixmaps; |
173 | QCanvasText *m_text; | 171 | QCanvasText *m_text; |
174 | Arrow *arrow; | 172 | Arrow *arrow; |
175 | 173 | ||
176 | QTimer *m_clock; | 174 | QTimer *m_clock; |
177 | bool m_running; | 175 | bool m_running; |
178 | int m_percent; | 176 | int m_percent; |
179 | bool m_pictured; | 177 | bool m_pictured; |
180 | 178 | ||
181 | }; | 179 | }; |
182 | 180 | ||
183 | #endif | 181 | #endif |