-rw-r--r-- | noncore/games/kbill/Game.cc | 14 | ||||
-rw-r--r-- | noncore/games/kbill/Game.h | 2 | ||||
-rw-r--r-- | noncore/games/kbill/field.cpp | 2 | ||||
-rw-r--r-- | noncore/games/kbill/inputbox.cpp | 10 | ||||
-rw-r--r-- | noncore/games/kbill/kbill.h | 42 |
5 files changed, 36 insertions, 34 deletions
diff --git a/noncore/games/kbill/Game.cc b/noncore/games/kbill/Game.cc index 624b50b..4cd5322 100644 --- a/noncore/games/kbill/Game.cc +++ b/noncore/games/kbill/Game.cc | |||
@@ -1,246 +1,246 @@ | |||
1 | #include "objects.h" | 1 | #include "objects.h" |
2 | 2 | ||
3 | Horde bill; | 3 | Horde bill; |
4 | Network net; | 4 | Network net; |
5 | Library OS; | 5 | Library OS; |
6 | Bucket bucket; | 6 | Bucket bucket; |
7 | Spark spark; | 7 | Spark spark; |
8 | //Scorelist scores; | 8 | //Scorelist scores; |
9 | Game game; | 9 | Game game; |
10 | UI ui; | 10 | UI ui; |
11 | 11 | ||
12 | int Game::RAND(int lb, int ub) { | 12 | int Game::RAND(int lb, int ub) { |
13 | return (rand()%(ub-lb+1) + lb); | 13 | return (rand()%(ub-lb+1) + lb); |
14 | } | 14 | } |
15 | 15 | ||
16 | int Game::MAX(int x, int y) { | 16 | int Game::MAX(int x, int y) { |
17 | return (x>y ? x : y); | 17 | return (x>y ? x : y); |
18 | } | 18 | } |
19 | 19 | ||
20 | int Game::MIN(int x, int y) { | 20 | int Game::MIN(int x, int y) { |
21 | return (x<y ? x : y); | 21 | return (x<y ? x : y); |
22 | } | 22 | } |
23 | 23 | ||
24 | int Game::INTERSECT(int x1, int y1, int w1, int h1, int x2, int y2, int w2, | 24 | int Game::INTERSECT(int x1, int y1, int w1, int h1, int x2, int y2, int w2, |
25 | int h2) | 25 | int h2) |
26 | { | 26 | { |
27 | return (((x2-x1<=w1 && x2-x1>=0) || (x1-x2<=w2 && x1-x2>=0)) | 27 | return (((x2-x1<=w1 && x2-x1>=0) || (x1-x2<=w2 && x1-x2>=0)) |
28 | && ((y2-y1<=h1 && y2-y1>=0) || (y1-y2<=h2 && y1-y2>=0))); | 28 | && ((y2-y1<=h1 && y2-y1>=0) || (y1-y2<=h2 && y1-y2>=0))); |
29 | } | 29 | } |
30 | 30 | ||
31 | void Game::setup_level (unsigned int lev) { | 31 | void Game::setup_level (unsigned int lev) { |
32 | level = lev; | 32 | level = lev; |
33 | bill.setup(); | 33 | bill.setup(); |
34 | grabbed = EMPTY; | 34 | grabbed = EMPTY; |
35 | ui.set_cursor(DEFAULTC); | 35 | ui.set_cursor(DEFAULTC); |
36 | net.setup(); | 36 | net.setup(); |
37 | iteration = efficiency = 0; | 37 | iteration = efficiency = 0; |
38 | } | 38 | } |
39 | 39 | ||
40 | void Game::start(unsigned int lev) { | 40 | void Game::start(unsigned int lev) { |
41 | state = PLAYING; | 41 | state = PLAYING; |
42 | score = 0; | 42 | score = 0; |
43 | ui.restart_timer(); | 43 | ui.restart_timer(); |
44 | ui.set_pausebutton(true); | 44 | ui.set_pausebutton(true); |
45 | setup_level(lev); | 45 | setup_level(lev); |
46 | } | 46 | } |
47 | 47 | ||
48 | void Game::quit() { | 48 | void Game::quit() { |
49 | 49 | ||
50 | exit(0); | 50 | exit(0); |
51 | } | 51 | } |
52 | 52 | ||
53 | void Game::update_info() { | 53 | void Game::update_info() { |
54 | static char str[80]; | 54 | static char str[80]; |
55 | sprintf (str, "Bill:%d/%d System:%d/%d/%d Level:%d Score:%d", | 55 | sprintf (str, "Bill:%d/%d System:%d/%d/%d Level:%d Score:%d", |
56 | bill.on_screen, bill.off_screen, net.base, net.off, | 56 | bill.on_screen, bill.off_screen, net.base, net.off, |
57 | net.win, level, score); | 57 | net.win, level, score); |
58 | ui.draw_str(str, 5, scrheight-5); | 58 | ui.draw_str(str, 5, scrheight-5); |
59 | efficiency += ((100*net.base-10*net.win)/net.units); | 59 | efficiency += ((100*net.base-10*net.win)/net.units); |
60 | } | 60 | } |
61 | 61 | ||
62 | void Game::update_score (int action) { | 62 | void Game::update_score (int action) { |
63 | switch (action){ | 63 | switch (action){ |
64 | case ENDLEVEL: score+=(level*efficiency/iteration); break; | 64 | case ENDLEVEL: score+=(level*efficiency/iteration); break; |
65 | default: score+=(action*action*BILLPOINTS); | 65 | default: score+=(action*action*BILLPOINTS); |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | void Game::warp_to_level (unsigned int lev) { | 69 | void Game::warp_to_level (unsigned int lev) { |
70 | if (state==PLAYING) { | 70 | if (state==PLAYING) { |
71 | if (lev <= level) return; | 71 | if (lev <= level) return; |
72 | setup_level(lev); | 72 | setup_level(lev); |
73 | } | 73 | } |
74 | else { | 74 | else { |
75 | if (lev<=0) return; | 75 | if (lev <=0) return; |
76 | start(lev); | 76 | start(lev); |
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | void Game::button_press(int x, int y) { | 80 | void Game::button_press(int x, int y) { |
81 | int i, counter=0, flag=0; | 81 | int i, counter=0, flag=0; |
82 | if (state != PLAYING) return; | 82 | if (state != PLAYING) return; |
83 | ui.set_cursor(DOWNC); | 83 | ui.set_cursor(DOWNC); |
84 | if (bucket.clicked(x, y)) { | 84 | if (bucket.clicked(x, y)) { |
85 | ui.set_cursor(BUCKETC); | 85 | ui.set_cursor(BUCKETC); |
86 | grabbed = BUCKET; | 86 | grabbed = BUCKET; |
87 | } | 87 | } |
88 | for (i=0; i < bill.MAX_BILLS && !flag; i++) { | 88 | for (i=0; i < bill.MAX_BILLS && !flag; i++) { |
89 | if (bill.list[i].state == bill.list[i].OFF | 89 | if (bill.list[i].state == bill.list[i].OFF |
90 | || bill.list[i].state == bill.list[i].DYING) | 90 | || bill.list[i].state == bill.list[i].DYING) |
91 | continue; | 91 | continue; |
92 | if (bill.list[i].state == bill.list[i].STRAY && | 92 | if (bill.list[i].state == bill.list[i].STRAY && |
93 | bill.list[i].clickedstray(x, y)) | 93 | bill.list[i].clickedstray(x, y)) |
94 | { | 94 | { |
95 | ui.set_cursor (bill.list[i].cargo); | 95 | ui.set_cursor (bill.list[i].cargo); |
96 | grabbed = i; | 96 | grabbed = i; |
97 | flag = 1; | 97 | flag = 1; |
98 | } | 98 | } |
99 | else if (bill.list[i].state != bill.list[i].STRAY && | 99 | else if (bill.list[i].state != bill.list[i].STRAY && |
100 | bill.list[i].clicked(x, y)) | 100 | bill.list[i].clicked(x, y)) |
101 | { | 101 | { |
102 | if (bill.list[i].state == bill.list[i].AT) | 102 | if (bill.list[i].state == bill.list[i].AT) |
103 | net.computers[bill.list[i].target_c].busy=0; | 103 | net.computers[bill.list[i].target_c].busy=0; |
104 | bill.list[i].index = -1; | 104 | bill.list[i].index = -1; |
105 | bill.list[i].cels = bill.dcels; | 105 | bill.list[i].cels = bill.dcels; |
106 | bill.list[i].x_offset = -2; | 106 | bill.list[i].x_offset = -2; |
107 | bill.list[i].y_offset = -15; | 107 | bill.list[i].y_offset = -15; |
108 | bill.list[i].state = bill.list[i].DYING; | 108 | bill.list[i].state = bill.list[i].DYING; |
109 | counter++; | 109 | counter++; |
110 | } | 110 | } |
111 | } | 111 | } |
112 | if (counter) update_score(counter); | 112 | if (counter) update_score(counter); |
113 | } | 113 | } |
114 | 114 | ||
115 | void Game::button_release(int x, int y) { | 115 | void Game::button_release(int x, int y) { |
116 | int i; | 116 | int i; |
117 | ui.set_cursor (DEFAULTC); | 117 | ui.set_cursor (DEFAULTC); |
118 | if (state != PLAYING || grabbed == EMPTY) | 118 | if (state != PLAYING || grabbed == EMPTY) |
119 | return; | 119 | return; |
120 | if (grabbed == BUCKET) { | 120 | if (grabbed == BUCKET) { |
121 | grabbed = EMPTY; | 121 | grabbed = EMPTY; |
122 | for (i=0; i<net.ncables; i++) | 122 | for (i=0; i<net.ncables; i++) |
123 | if (net.cables[i].onspark(x, y)) { | 123 | if (net.cables[i].onspark(x, y)) { |
124 | net.cables[i].active=0; | 124 | net.cables[i].active=0; |
125 | net.cables[i].delay = spark.delay(level); | 125 | net.cables[i].delay = spark.delay(level); |
126 | } | 126 | } |
127 | return; | 127 | return; |
128 | } | 128 | } |
129 | for (i=0; i<net.units; i++) | 129 | for (i=0; i<net.units; i++) |
130 | if (net.computers[i].oncomputer(x, y) | 130 | if (net.computers[i].oncomputer(x, y) |
131 | && | 131 | && |
132 | net.computers[i].compatible (bill.list[grabbed].cargo) | 132 | net.computers[i].compatible (bill.list[grabbed].cargo) |
133 | && | 133 | && |
134 | (net.computers[i].os == OS.WINGDOWS || | 134 | (net.computers[i].os == OS.WINGDOWS || |
135 | net.computers[i].os == OS.OFF)) | 135 | net.computers[i].os == OS.OFF)) |
136 | { | 136 | { |
137 | net.base++; | 137 | net.base++; |
138 | if (net.computers[i].os == OS.WINGDOWS) | 138 | if (net.computers[i].os == OS.WINGDOWS) |
139 | net.win--; | 139 | net.win--; |
140 | else | 140 | else |
141 | net.off--; | 141 | net.off--; |
142 | net.computers[i].os = bill.list[grabbed].cargo; | 142 | net.computers[i].os = bill.list[grabbed].cargo; |
143 | bill.list[grabbed].state = bill.list[grabbed].OFF; | 143 | bill.list[grabbed].state = bill.list[grabbed].OFF; |
144 | grabbed = EMPTY; | 144 | grabbed = EMPTY; |
145 | return; | 145 | return; |
146 | } | 146 | } |
147 | grabbed = EMPTY; | 147 | grabbed = EMPTY; |
148 | } | 148 | } |
149 | 149 | ||
150 | void Game::update() { | 150 | void Game::update() { |
151 | switch (state) { | 151 | switch (state) { |
152 | case PLAYING: | 152 | case PLAYING: |
153 | ui.clear(); | 153 | ui.clear(); |
154 | bucket.draw(); | 154 | bucket.draw(); |
155 | net.update(); | 155 | net.update(); |
156 | net.draw(); | 156 | net.draw(); |
157 | bill.update(); | 157 | bill.update(); |
158 | bill.draw(); | 158 | bill.draw(); |
159 | update_info(); | 159 | update_info(); |
160 | if (!(bill.on_screen+bill.off_screen)) { | 160 | if (!(bill.on_screen+bill.off_screen)) { |
161 | update_score(ENDLEVEL); | 161 | update_score(ENDLEVEL); |
162 | state = BETWEEN; | 162 | state = BETWEEN; |
163 | } | 163 | } |
164 | if ((net.base+net.off)<=1) state = END; | 164 | if ((net.base+net.off)<=1) state = END; |
165 | break; | 165 | break; |
166 | case END: | 166 | case END: |
167 | ui.clear(); | 167 | ui.clear(); |
168 | net.toasters(); | 168 | net.toasters(); |
169 | net.draw(); | 169 | net.draw(); |
170 | ui.refresh(); | 170 | ui.refresh(); |
171 | ui.popup_dialog(ENDGAME); | 171 | ui.popup_dialog(ENDGAME); |
172 | /* if (score > scores.score[9]) ui.popup_dialog(ENTERNAME); | 172 | /* if (score > scores.score[9]) ui.popup_dialog(ENTERNAME); |
173 | scores.update();*/ | 173 | scores.update();*/ |
174 | ui.popup_dialog(HIGHSCORE); | 174 | ui.popup_dialog(HIGHSCORE); |
175 | ui.clear(); | 175 | ui.clear(); |
176 | ui.draw_centered(logo); | 176 | ui.draw_centered(logo); |
177 | ui.kill_timer(); | 177 | ui.kill_timer(); |
178 | ui.set_pausebutton (false); | 178 | ui.set_pausebutton (false); |
179 | state = WAITING; | 179 | state = WAITING; |
180 | break; | 180 | break; |
181 | case BETWEEN: | 181 | case BETWEEN: |
182 | ui.update_scorebox(level, score); | 182 | ui.update_scorebox(level, score); |
183 | ui.popup_dialog (SCORE); | 183 | ui.popup_dialog (SCORE); |
184 | state = PLAYING; | 184 | state = PLAYING; |
185 | setup_level(++level); | 185 | setup_level(++level); |
186 | break; | 186 | break; |
187 | } | 187 | } |
188 | ui.refresh(); | 188 | ui.refresh(); |
189 | iteration++; | 189 | iteration++; |
190 | } | 190 | } |
191 | 191 | ||
192 | void Game::main(int argc, char **argv) { | 192 | void Game::main(int argc, char **argv) { |
193 | int c; | 193 | int c; |
194 | extern char *optarg; | 194 | extern char *optarg; |
195 | 195 | ||
196 | level = 0; | 196 | level = 0; |
197 | ui.initialize(&argc, argv); | 197 | ui.initialize(&argc, argv); |
198 | while (argv && argv[0] && (c = getopt(argc, argv, "l:L:")) != -1) | 198 | while (argv && argv[0] && (c = getopt(argc, argv, "l:L:")) != -1) |
199 | switch(c) { | 199 | switch(c) { |
200 | case 'l': | 200 | case 'l': |
201 | case 'L': level = MAX (1, atoi(optarg)); break; | 201 | case 'L': level = MAX (1, atoi(optarg)); break; |
202 | } | 202 | } |
203 | srand(time(NULL)); | 203 | srand(time(NULL)); |
204 | ui.make_mainwin(); | 204 | ui.make_mainwin(); |
205 | ui.graph_init(); | 205 | ui.graph_init(); |
206 | ui.clear(); | 206 | ui.clear(); |
207 | logo.load("logo"); | 207 | logo.load("logo"); |
208 | ui.draw_centered(logo); | 208 | ui.draw_centered(logo); |
209 | ui.refresh(); | 209 | ui.refresh(); |
210 | ui.make_windows(); | 210 | ui.make_windows(); |
211 | // scores.read(); | 211 | // scores.read(); |
212 | // scores.update(); | 212 | // scores.update(); |
213 | 213 | ||
214 | bill.load_pix(); | 214 | bill.load_pix(); |
215 | OS.load_pix(); | 215 | OS.load_pix(); |
216 | net.load_pix(); | 216 | net.load_pix(); |
217 | bucket.load_pix(); | 217 | bucket.load_pix(); |
218 | spark.load_pix(); | 218 | spark.load_pix(); |
219 | 219 | ||
220 | ui.load_cursors(); | 220 | ui.load_cursors(); |
221 | 221 | ||
222 | state = WAITING; | 222 | state = WAITING; |
223 | if (level) start(level); | 223 | if (level) start(level); |
224 | else ui.set_pausebutton(false); | 224 | else ui.set_pausebutton(false); |
225 | ui.MainLoop(); | 225 | ui.MainLoop(); |
226 | exit(0); | 226 | exit(0); |
227 | } | 227 | } |
228 | 228 | ||
229 | int main(int argc, char **argv) { | 229 | int main(int argc, char **argv) { |
230 | if (argc>1 && !strcmp(argv[1], "-v")) { | 230 | if (argc>1 && !strcmp(argv[1], "-v")) { |
231 | printf ("XBill version 2.0\n\n"); | 231 | printf ("XBill version 2.0\n\n"); |
232 | exit(0); | 232 | exit(0); |
233 | } | 233 | } |
234 | if (argc>1 && !strcmp(argv[1], "-h")) { | 234 | if (argc>1 && !strcmp(argv[1], "-h")) { |
235 | printf ("XBill version 2.0\n"); | 235 | printf ("XBill version 2.0\n"); |
236 | printf ("Options:\n"); | 236 | printf ("Options:\n"); |
237 | printf ("-l n, -L n\tStart at level n.\n"); | 237 | printf ("-l n, -L n\tStart at level n.\n"); |
238 | printf ("-v\t\tPrint version number and exit.\n"); | 238 | printf ("-v\t\tPrint version number and exit.\n"); |
239 | printf ("-h\t\tPrint help and exit.\n"); | 239 | printf ("-h\t\tPrint help and exit.\n"); |
240 | printf ("leaves the window.\n"); | 240 | printf ("leaves the window.\n"); |
241 | printf ("All standard X Intrinsics options are also "); | 241 | printf ("All standard X Intrinsics options are also "); |
242 | printf ("supported.\n\n"); | 242 | printf ("supported.\n\n"); |
243 | exit(0); | 243 | exit(0); |
244 | } | 244 | } |
245 | game.main(argc, argv); | 245 | game.main(argc, argv); |
246 | } | 246 | } |
diff --git a/noncore/games/kbill/Game.h b/noncore/games/kbill/Game.h index 4473936..5c9c497 100644 --- a/noncore/games/kbill/Game.h +++ b/noncore/games/kbill/Game.h | |||
@@ -1,55 +1,55 @@ | |||
1 | #ifndef GAME_H | 1 | #ifndef GAME_H |
2 | #define GAME_H | 2 | #define GAME_H |
3 | 3 | ||
4 | #include "objects.h" | 4 | #include "objects.h" |
5 | 5 | ||
6 | class Game { | 6 | class Game { |
7 | unsigned state; | 7 | int state; |
8 | int efficiency; | 8 | int efficiency; |
9 | public: | 9 | public: |
10 | unsigned score, level, iteration; | 10 | unsigned score, level, iteration; |
11 | Picture logo; | 11 | Picture logo; |
12 | int grabbed; | 12 | int grabbed; |
13 | 13 | ||
14 | static const unsigned short scrwidth = 240; | 14 | static const unsigned short scrwidth = 240; |
15 | static const unsigned short scrheight = 290; | 15 | static const unsigned short scrheight = 290; |
16 | 16 | ||
17 | static const int PLAYING = 1; | 17 | static const int PLAYING = 1; |
18 | static const int BETWEEN = 2; | 18 | static const int BETWEEN = 2; |
19 | static const int END = 3; | 19 | static const int END = 3; |
20 | static const int WAITING = 4; | 20 | static const int WAITING = 4; |
21 | 21 | ||
22 | static const int DEFAULTC = 0; /* cursors */ | 22 | static const int DEFAULTC = 0; /* cursors */ |
23 | static const int DOWNC = -1; | 23 | static const int DOWNC = -1; |
24 | static const int BUCKETC = -2; | 24 | static const int BUCKETC = -2; |
25 | 25 | ||
26 | static const int ENDGAME = 200; /* dialog window IDs */ | 26 | static const int ENDGAME = 200; /* dialog window IDs */ |
27 | static const int ENTERNAME = 201; | 27 | static const int ENTERNAME = 201; |
28 | static const int HIGHSCORE = 202; | 28 | static const int HIGHSCORE = 202; |
29 | static const int SCORE = 203; | 29 | static const int SCORE = 203; |
30 | 30 | ||
31 | static const int ENDLEVEL = -1; /* Codes for updating score */ | 31 | static const int ENDLEVEL = -1; /* Codes for updating score */ |
32 | static const int BILLPOINTS = 5; | 32 | static const int BILLPOINTS = 5; |
33 | 33 | ||
34 | static const int EMPTY = -2; /* Grabbed object */ | 34 | static const int EMPTY = -2; /* Grabbed object */ |
35 | static const int BUCKET = -1; | 35 | static const int BUCKET = -1; |
36 | 36 | ||
37 | int RAND(int lb, int ub); | 37 | int RAND(int lb, int ub); |
38 | int MAX(int x, int y); | 38 | int MAX(int x, int y); |
39 | int MIN(int x, int y); | 39 | int MIN(int x, int y); |
40 | int INTERSECT(int x1, int y1, int w1, int h1, int x2, int y2, int w2, | 40 | int INTERSECT(int x1, int y1, int w1, int h1, int x2, int y2, int w2, |
41 | int h2); | 41 | int h2); |
42 | 42 | ||
43 | void setup_level (unsigned int lev); | 43 | void setup_level (unsigned int lev); |
44 | void start(unsigned int lev); | 44 | void start(unsigned int lev); |
45 | void quit(); | 45 | void quit(); |
46 | void update_info(); | 46 | void update_info(); |
47 | void update_score (int action); | 47 | void update_score (int action); |
48 | void warp_to_level (unsigned int lev); | 48 | void warp_to_level (unsigned int lev); |
49 | void button_press(int x, int y); | 49 | void button_press(int x, int y); |
50 | void button_release(int x, int y); | 50 | void button_release(int x, int y); |
51 | void update(); | 51 | void update(); |
52 | void main(int argc, char **argv); | 52 | void main(int argc, char **argv); |
53 | }; | 53 | }; |
54 | 54 | ||
55 | #endif | 55 | #endif |
diff --git a/noncore/games/kbill/field.cpp b/noncore/games/kbill/field.cpp index a974ab2..0dd8d72 100644 --- a/noncore/games/kbill/field.cpp +++ b/noncore/games/kbill/field.cpp | |||
@@ -1,83 +1,83 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | field.cpp - description | 2 | field.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Thu Dec 30 1999 | 4 | begin : Thu Dec 30 1999 |
5 | copyright : (C) 1999 by Jurrien Loonstra | 5 | copyright : (C) 1999 by Jurrien Loonstra |
6 | email : j.h.loonstra@st.hanze.nl | 6 | email : j.h.loonstra@st.hanze.nl |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | 18 | ||
19 | #include "objects.h" | 19 | #include "objects.h" |
20 | 20 | ||
21 | #include "field.h" | 21 | #include "field.h" |
22 | 22 | ||
23 | Field::Field(QWidget *parent, const char *name ) : QWidget(parent,name) { | 23 | Field::Field(QWidget *parent, const char *name ) : QWidget(parent,name) { |
24 | setFixedSize(game.scrwidth, game.scrheight); | 24 | setFixedSize(game.scrwidth, game.scrheight); |
25 | setBackgroundColor(white); | 25 | setBackgroundColor(white); |
26 | timer = new QTimer(this); | 26 | timer = new QTimer(this); |
27 | 27 | ||
28 | playing = false; | 28 | playing = false; |
29 | 29 | ||
30 | connect(timer, SIGNAL(timeout()), SLOT(Timer())); | 30 | connect(timer, SIGNAL(timeout()), SLOT(Timer())); |
31 | } | 31 | } |
32 | 32 | ||
33 | Field::~Field(){ | 33 | Field::~Field(){ |
34 | delete timer; | 34 | delete timer; |
35 | } | 35 | } |
36 | 36 | ||
37 | void Field::setPixmap(QPixmap *pix) { | 37 | void Field::setPixmap(QPixmap *pix) { |
38 | this->pix = pix; | 38 | this->pix = pix; |
39 | } | 39 | } |
40 | 40 | ||
41 | // -------------------------------------------------------- | 41 | // -------------------------------------------------------- |
42 | 42 | ||
43 | void Field::mousePressEvent(QMouseEvent *e){ | 43 | void Field::mousePressEvent(QMouseEvent *e){ |
44 | game.button_press(e->x(), e->y()); | 44 | game.button_press(e->x(), e->y()); |
45 | } | 45 | } |
46 | 46 | ||
47 | void Field::mouseReleaseEvent(QMouseEvent *e){ | 47 | void Field::mouseReleaseEvent(QMouseEvent *e){ |
48 | game.button_release(e->x(), e->y()); | 48 | game.button_release(e->x(), e->y()); |
49 | } | 49 | } |
50 | 50 | ||
51 | void Field::enterEvent(QEvent *) { | 51 | void Field::enterEvent(QEvent *) { |
52 | if (playing && !timer->isActive()) { | 52 | if (playing && !timer->isActive()) { |
53 | playing = true; | 53 | playing = true; |
54 | timer->start(250, FALSE); | 54 | timer->start(250, FALSE); |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | void Field::leaveEvent(QEvent *) { | 58 | void Field::leaveEvent(QEvent *) { |
59 | if (timer->isActive() && playing) { | 59 | if (timer->isActive() && playing) { |
60 | playing = true; | 60 | playing = true; |
61 | timer->stop(); | 61 | timer->stop(); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | void Field::stopTimer() { | 65 | void Field::stopTimer() { |
66 | playing = false; | 66 | playing = false; |
67 | if (timer->isActive()) | 67 | if (timer->isActive()) |
68 | timer->stop(); | 68 | timer->stop(); |
69 | } | 69 | } |
70 | 70 | ||
71 | void Field::startTimer() { | 71 | void Field::startTimer() { |
72 | playing = true; | 72 | playing = true; |
73 | if (!timer->isActive()) | 73 | if (!timer->isActive()) |
74 | timer->start(250, FALSE); | 74 | timer->start(250, FALSE); |
75 | } | 75 | } |
76 | 76 | ||
77 | void Field::Timer(){ | 77 | void Field::Timer(){ |
78 | game.update(); | 78 | game.update(); |
79 | } | 79 | } |
80 | 80 | ||
81 | void Field::paintEvent(QPaintEvent *) { | 81 | void Field::paintEvent(QPaintEvent *) { |
82 | bitBlt(this, 0, 0, pix); | 82 | bitBlt(this, 0, 0, pix); |
83 | } \ No newline at end of file | 83 | } |
diff --git a/noncore/games/kbill/inputbox.cpp b/noncore/games/kbill/inputbox.cpp index 5087fbb..7aaebe7 100644 --- a/noncore/games/kbill/inputbox.cpp +++ b/noncore/games/kbill/inputbox.cpp | |||
@@ -1,50 +1,50 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | inputbox.cpp - description | 2 | inputbox.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Sat Jan 1 2000 | 4 | begin : Sat Jan 1 2000 |
5 | copyright : (C) 2000 by Jurrien Loonstra | 5 | copyright : (C) 2000 by Jurrien Loonstra |
6 | email : j.h.loonstra@st.hanze.nl | 6 | email : j.h.loonstra@st.hanze.nl |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include "inputbox.h" | 18 | #include "inputbox.h" |
19 | InputBox::InputBox(QWidget *parent, const char *name, const char *caption, const char *text) : QDialog(parent, name, TRUE) { | 19 | InputBox::InputBox(QWidget *parent, const char *name, const char *, const char *) : QDialog(parent, name, TRUE) { |
20 | // setCaption(caption); | 20 | // setCaption(caption); |
21 | // | 21 | // |
22 | // question = new QLabel(this); | 22 | // question = new QLabel(this); |
23 | // question->setText(text); | 23 | // question->setText(text); |
24 | // question->setGeometry(10, 10, 240, 50); | 24 | // question->setGeometry(10, 10, 240, 50); |
25 | // | 25 | // |
26 | // input = new QLineEdit(this); | 26 | // input = new QLineEdit(this); |
27 | // input->setGeometry(10, 60, 240, 30); | 27 | // input->setGeometry(10, 60, 240, 30); |
28 | // input->setFocus(); | 28 | // input->setFocus(); |
29 | // input->setMaxLength(19); | 29 | // input->setMaxLength(19); |
30 | // | 30 | // |
31 | // ok = new QPushButton( "Ok", this ); | 31 | // ok = new QPushButton( "Ok", this ); |
32 | // ok->setGeometry(10, 100, 100,30 ); | 32 | // ok->setGeometry(10, 100, 100,30 ); |
33 | // ok->setDefault(TRUE); | 33 | // ok->setDefault(TRUE); |
34 | // connect( ok, SIGNAL(clicked()), SLOT(accept()) ); | 34 | // connect( ok, SIGNAL(clicked()), SLOT(accept()) ); |
35 | // | 35 | // |
36 | // cancel = new QPushButton( "Cancel", this ); | 36 | // cancel = new QPushButton( "Cancel", this ); |
37 | // cancel->setGeometry(150, 100, 100,30 ); | 37 | // cancel->setGeometry(150, 100, 100,30 ); |
38 | // connect( cancel, SIGNAL(clicked()), SLOT(reject()) ); | 38 | // connect( cancel, SIGNAL(clicked()), SLOT(reject()) ); |
39 | } | 39 | } |
40 | 40 | ||
41 | InputBox::~InputBox(){ | 41 | InputBox::~InputBox(){ |
42 | delete ok; | 42 | delete ok; |
43 | delete cancel; | 43 | delete cancel; |
44 | delete question; | 44 | delete question; |
45 | delete input; | 45 | delete input; |
46 | } | 46 | } |
47 | 47 | ||
48 | QString InputBox::getText() const{ | 48 | QString InputBox::getText() const{ |
49 | return input->text(); | 49 | return input->text(); |
50 | } | 50 | } |
diff --git a/noncore/games/kbill/kbill.h b/noncore/games/kbill/kbill.h index fbc0c6c..da1a111 100644 --- a/noncore/games/kbill/kbill.h +++ b/noncore/games/kbill/kbill.h | |||
@@ -1,54 +1,56 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | kbill.h - description | 2 | kbill.h - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Thu Dec 30 16:55:55 CET 1999 | 4 | begin : Thu Dec 30 16:55:55 CET 1999 |
5 | copyright : (C) 1999 by Jurrien Loonstra | 5 | copyright : (C) 1999 by Jurrien Loonstra |
6 | email : j.h.loonstra@st.hanze.nl | 6 | email : j.h.loonstra@st.hanze.nl |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #ifndef KBILL_H | 18 | #ifndef KBILL_H |
19 | #define KBILL_H | 19 | #define KBILL_H |
20 | 20 | ||
21 | 21 | ||
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qpopupmenu.h> | 25 | #include <qpopupmenu.h> |
26 | 26 | ||
27 | #include "field.h" | 27 | #include "field.h" |
28 | 28 | ||
29 | class KBill : public QMainWindow | 29 | class KBill : public QMainWindow |
30 | { | 30 | { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | public: | 32 | public: |
33 | KBill(); | 33 | KBill(); |
34 | ~KBill(); | 34 | ~KBill(); |
35 | Field* getField(); | 35 | Field* getField(); |
36 | private: | 36 | private: |
37 | QMenuBar *menu; | 37 | QMenuBar *menu; |
38 | QPopupMenu *file, *help; | 38 | QPopupMenu *file, *help; |
39 | Field *field; | 39 | Field *field; |
40 | int pauseid; | 40 | int pauseid; |
41 | protected slots: | 41 | |
42 | void Quit(); | 42 | protected slots: |
43 | void About(); | 43 | void Quit(); |
44 | void NewGame(); | 44 | void About(); |
45 | void Pause(); | 45 | void NewGame(); |
46 | void WarpTo(); | 46 | void Pause(); |
47 | void Story(); | 47 | void WarpTo(); |
48 | void Rules(); | 48 | void Story(); |
49 | void ViewHighScores(); | 49 | void Rules(); |
50 | 50 | void ViewHighScores(); | |
51 | friend class UI; | 51 | |
52 | protected: | ||
53 | friend class UI; | ||
52 | }; | 54 | }; |
53 | 55 | ||
54 | #endif | 56 | #endif |