summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/kbill/Bucket.cc16
-rw-r--r--noncore/games/kbill/Bucket.h17
-rw-r--r--noncore/games/kbill/Cable.cc94
-rw-r--r--noncore/games/kbill/Cable.h20
-rw-r--r--noncore/games/kbill/Computer.cc56
-rw-r--r--noncore/games/kbill/Computer.h22
-rw-r--r--noncore/games/kbill/Game.cc246
-rw-r--r--noncore/games/kbill/Game.h55
-rw-r--r--noncore/games/kbill/Horde.cc64
-rw-r--r--noncore/games/kbill/Horde.h27
-rw-r--r--noncore/games/kbill/Library.cc13
-rw-r--r--noncore/games/kbill/Library.h19
-rw-r--r--noncore/games/kbill/MCursor.cc69
-rw-r--r--noncore/games/kbill/MCursor.h37
-rw-r--r--noncore/games/kbill/Makefile533
-rw-r--r--noncore/games/kbill/Makefile.am59
-rw-r--r--noncore/games/kbill/Makefile.in427
-rw-r--r--noncore/games/kbill/Monster.cc226
-rw-r--r--noncore/games/kbill/Monster.h53
-rw-r--r--noncore/games/kbill/Network.cc49
-rw-r--r--noncore/games/kbill/Network.h27
-rw-r--r--noncore/games/kbill/Picture.cc72
-rw-r--r--noncore/games/kbill/Picture.h32
-rw-r--r--noncore/games/kbill/Scorelist.cc75
-rw-r--r--noncore/games/kbill/Scorelist.h16
-rw-r--r--noncore/games/kbill/Spark.cc13
-rw-r--r--noncore/games/kbill/Spark.h16
-rw-r--r--noncore/games/kbill/Strings.h58
-rw-r--r--noncore/games/kbill/UI.cpp175
-rw-r--r--noncore/games/kbill/UI.h73
-rw-r--r--noncore/games/kbill/field.cpp84
-rw-r--r--noncore/games/kbill/field.h48
-rw-r--r--noncore/games/kbill/inputbox.cpp51
-rw-r--r--noncore/games/kbill/inputbox.h39
-rw-r--r--noncore/games/kbill/kbill.cpp118
-rw-r--r--noncore/games/kbill/kbill.h54
-rw-r--r--noncore/games/kbill/kbill.pro13
-rw-r--r--noncore/games/kbill/kbill.xpm69
-rw-r--r--noncore/games/kbill/mini-kbill.xpm248
-rw-r--r--noncore/games/kbill/objects.h26
40 files changed, 3409 insertions, 0 deletions
diff --git a/noncore/games/kbill/Bucket.cc b/noncore/games/kbill/Bucket.cc
new file mode 100644
index 0000000..4b1d82a
--- a/dev/null
+++ b/noncore/games/kbill/Bucket.cc
@@ -0,0 +1,16 @@
1#include "objects.h"
2
3int Bucket::clicked (int x, int y) {
4 return (x > 0 && y > 0 && x < width && y < height);
5}
6
7void Bucket::draw() {
8 if (game.grabbed != game.BUCKET) ui.draw(picture, 0, 0);
9}
10
11void Bucket::load_pix() {
12 picture.load("bucket");
13 cursor.load("bucket", cursor.OWN_MASK);
14 width = picture.width;
15 height = picture.height;
16}
diff --git a/noncore/games/kbill/Bucket.h b/noncore/games/kbill/Bucket.h
new file mode 100644
index 0000000..d8a2144
--- a/dev/null
+++ b/noncore/games/kbill/Bucket.h
@@ -0,0 +1,17 @@
1#ifndef BUCKET_H
2#define BUCKET_H
3
4#include "Picture.h"
5#include "MCursor.h"
6
7class Bucket {
8public:
9 Picture picture;
10 MCursor cursor;
11 int width, height;
12 void draw();
13 int clicked(int x, int y);
14 void load_pix();
15};
16
17#endif
diff --git a/noncore/games/kbill/Cable.cc b/noncore/games/kbill/Cable.cc
new file mode 100644
index 0000000..6fdb3d1
--- a/dev/null
+++ b/noncore/games/kbill/Cable.cc
@@ -0,0 +1,94 @@
1#include "objects.h"
2
3void Cable::setup() {
4 c1 = game.RAND(0, net.units-1);
5 do {
6 c2 = game.RAND(0, net.units-1);
7 } while (c2 == c1);
8 active = index = 0;
9 delay = spark.delay(game.level);
10 x1 = net.computers[c1].x + net.width/3;
11 x2 = net.computers[c2].x + net.width/3;
12 y1 = net.computers[c1].y + net.height/2;
13 y2 = net.computers[c2].y + net.height/2;
14}
15
16void Cable::update () {
17 if (active) {
18 if ((net.computers[c1].os == OS.WINGDOWS) ==
19 (net.computers[c2].os == OS.WINGDOWS))
20 active=0;
21 else if (net.computers[c1].os == OS.WINGDOWS ||
22 net.computers[c2].os == OS.WINGDOWS)
23 {
24 int dir, xdist, ydist,c;
25 float sx, sy;
26 dir = (net.computers[c2].os == OS.WINGDOWS);
27 if (dir)
28 {xdist=x1-x; ydist=y1-y;}
29 else
30 {xdist=x2-x; ydist=y2-y;}
31 sx = xdist >= 0 ? 1.0 : -1.0;
32 sy = ydist >= 0 ? 1.0 : -1.0;
33 xdist = abs(xdist);
34 ydist = abs(ydist);
35 if (xdist==0 && ydist==0) {
36 if (dir==0) c=c2; else c=c1;
37 if (!net.computers[c].busy) {
38 if (net.computers[c].os == OS.OFF)
39 net.off--;
40 else
41 net.base--;
42 net.win++;
43 net.computers[c].os=OS.WINGDOWS;
44 }
45 active=0;
46 }
47 else if (game.MAX (xdist, ydist) < spark.speed) {
48 if (dir)
49 {x = x1; y = y1;}
50 else
51 {x = x2; y = y2;}
52 }
53 else {
54 fx+=(xdist*spark.speed*sx)/(xdist+ydist);
55 fy+=(ydist*spark.speed*sy)/(xdist+ydist);
56 x = (int)fx;
57 y = (int)fy;
58 }
59 index = 1 - index;
60 }
61 }
62 else {
63 if ((net.computers[c1].os == OS.WINGDOWS) ==
64 (net.computers[c2].os == OS.WINGDOWS))
65 delay = spark.delay(game.level);
66 else if (net.computers[c1].os == OS.WINGDOWS ||
67 net.computers[c2].os == OS.WINGDOWS)
68 {
69 if (delay>0) delay--;
70 else {
71 active = 1;
72 if (net.computers[c1].os == OS.WINGDOWS)
73 {fx=x=x1; fy=y=y1;}
74 else
75 {fx=x=x2; fy=y=y2;}
76 }
77 }
78 }
79}
80
81int Cable::onspark (int locx, int locy) {
82 if (!active) return 0;
83 return (abs(locx-x) < spark.width
84 && abs(locy-y) < spark.height);
85}
86
87void Cable::draw() {
88 int rx = x - spark.width/2;
89 int ry = y - spark.height/2;
90 ui.draw_line(x1,y1,x2,y2);
91 if (active)
92 ui.draw(spark.pictures[index], rx, ry);
93}
94
diff --git a/noncore/games/kbill/Cable.h b/noncore/games/kbill/Cable.h
new file mode 100644
index 0000000..bb6c31c
--- a/dev/null
+++ b/noncore/games/kbill/Cable.h
@@ -0,0 +1,20 @@
1#ifndef CABLE_H
2#define CABLE_H
3
4class Cable {
5public:
6 int c1, c2; /*computers connected */
7 int x1,y1,x2,y2;/*endpoints of line representing cable */
8 int x, y; /*current location of spark*/
9 float fx, fy; /*needed for line drawing*/
10 int delay; /*how much time until spark leaves*/
11 int active; /*is spark moving and from which end*/
12 int index;
13 void setup();
14 void draw();
15 void update();
16 int onspark (int locx, int locy);
17
18};
19
20#endif
diff --git a/noncore/games/kbill/Computer.cc b/noncore/games/kbill/Computer.cc
new file mode 100644
index 0000000..7bd4bd3
--- a/dev/null
+++ b/noncore/games/kbill/Computer.cc
@@ -0,0 +1,56 @@
1#include "objects.h"
2
3int Computer::setup(int i) {
4 int j, counter=0, flag;
5 do {
6 if (++counter>4000) return 0;
7 x = game.RAND(BORDER, game.scrwidth - BORDER - net.width);
8 y = game.RAND(BORDER, game.scrheight - BORDER - net.height);
9 flag=1;
10 /*checks for conflicting computer placement*/
11 for (j=0; j<i && flag; j++)
12 if (game.INTERSECT(x, y,
13 net.width-bill.list[0].XOFFSET+bill.width,
14 net.height, net.computers[j].x,
15 net.computers[j].y,
16 net.width-bill.list[0].XOFFSET+bill.width,
17 net.height))
18 flag=0;
19 } while (!flag);
20 type = game.RAND(1, net.NUM_SYS);
21 os = determineOS();
22 busy=0;
23 return 1;
24}
25
26int Computer::find_stray() {
27 int i;
28 for (i=0; i < bill.MAX_BILLS; i++) {
29 if (bill.list[i].state != bill.list[i].STRAY) continue;
30 if (game.INTERSECT(x, y, net.width, net.height, bill.list[i].x,
31 bill.list[i].y, OS.width, OS.height))
32 return i;
33 }
34 return -1;
35}
36
37int Computer::oncomputer (int locx, int locy) {
38 return (abs(locx-x) < net.width && abs(locy-y) < net.height);
39}
40
41int Computer::compatible (int system) {
42 return (type==system || (type>=PC && system>=OS.PC));
43}
44
45int Computer::determineOS() {
46 if (type<PC) return type;
47 else return game.RAND (OS.PC, OS.NUM_OS);
48}
49
50void Computer::draw() {
51 ui.draw(net.pictures[type], x, y);
52 if (os != OS.OFF)
53 ui.draw(OS.os[os], x + OFFSET, y + OFFSET);
54}
55
56
diff --git a/noncore/games/kbill/Computer.h b/noncore/games/kbill/Computer.h
new file mode 100644
index 0000000..7edcafb
--- a/dev/null
+++ b/noncore/games/kbill/Computer.h
@@ -0,0 +1,22 @@
1#ifndef COMPUTER_H
2#define COMPUTER_H
3
4 class Computer {/*structure for Computers*/
5public:
6 int type; /*CPU type*/
7 int os; /*current OS*/
8 int x, y; /*location*/
9 int busy; /*is the computer being used?*/
10 int setup(int i);
11 void draw();
12 int find_stray();
13 int oncomputer (int locx, int locy);
14 int compatible(int system);
15 int determineOS();
16 static const int TOASTER = 0;/* computer 0 is a toaster */
17 static const int PC = 5;/* type>=PC means the computer is a PC*/
18 static const int OFFSET = 4;/* offset of screen from 0,0 */
19 static const int BORDER = 50;/* BORDER pixels free on all sides*/
20};
21
22#endif
diff --git a/noncore/games/kbill/Game.cc b/noncore/games/kbill/Game.cc
new file mode 100644
index 0000000..624b50b
--- a/dev/null
+++ b/noncore/games/kbill/Game.cc
@@ -0,0 +1,246 @@
1#include "objects.h"
2
3Horde bill;
4Network net;
5Library OS;
6Bucket bucket;
7Spark spark;
8//Scorelist scores;
9Game game;
10UI ui;
11
12int Game::RAND(int lb, int ub) {
13 return (rand()%(ub-lb+1) + lb);
14}
15
16int Game::MAX(int x, int y) {
17 return (x>y ? x : y);
18}
19
20int Game::MIN(int x, int y) {
21 return (x<y ? x : y);
22}
23
24int Game::INTERSECT(int x1, int y1, int w1, int h1, int x2, int y2, int w2,
25 int h2)
26{
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)));
29}
30
31void Game::setup_level (unsigned int lev) {
32 level = lev;
33 bill.setup();
34 grabbed = EMPTY;
35 ui.set_cursor(DEFAULTC);
36 net.setup();
37 iteration = efficiency = 0;
38}
39
40void Game::start(unsigned int lev) {
41 state = PLAYING;
42 score = 0;
43 ui.restart_timer();
44 ui.set_pausebutton(true);
45 setup_level(lev);
46}
47
48void Game::quit() {
49
50 exit(0);
51}
52
53void Game::update_info() {
54 static char str[80];
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,
57 net.win, level, score);
58 ui.draw_str(str, 5, scrheight-5);
59 efficiency += ((100*net.base-10*net.win)/net.units);
60}
61
62void Game::update_score (int action) {
63 switch (action){
64 case ENDLEVEL: score+=(level*efficiency/iteration); break;
65 default: score+=(action*action*BILLPOINTS);
66 }
67}
68
69void Game::warp_to_level (unsigned int lev) {
70 if (state==PLAYING) {
71 if (lev <= level) return;
72 setup_level(lev);
73 }
74 else {
75 if (lev<=0) return;
76 start(lev);
77 }
78}
79
80void Game::button_press(int x, int y) {
81 int i, counter=0, flag=0;
82 if (state != PLAYING) return;
83 ui.set_cursor(DOWNC);
84 if (bucket.clicked(x, y)) {
85 ui.set_cursor(BUCKETC);
86 grabbed = BUCKET;
87 }
88 for (i=0; i < bill.MAX_BILLS && !flag; i++) {
89 if (bill.list[i].state == bill.list[i].OFF
90 || bill.list[i].state == bill.list[i].DYING)
91 continue;
92 if (bill.list[i].state == bill.list[i].STRAY &&
93 bill.list[i].clickedstray(x, y))
94 {
95 ui.set_cursor (bill.list[i].cargo);
96 grabbed = i;
97 flag = 1;
98 }
99 else if (bill.list[i].state != bill.list[i].STRAY &&
100 bill.list[i].clicked(x, y))
101 {
102 if (bill.list[i].state == bill.list[i].AT)
103 net.computers[bill.list[i].target_c].busy=0;
104 bill.list[i].index = -1;
105 bill.list[i].cels = bill.dcels;
106 bill.list[i].x_offset = -2;
107 bill.list[i].y_offset = -15;
108 bill.list[i].state = bill.list[i].DYING;
109 counter++;
110 }
111 }
112 if (counter) update_score(counter);
113}
114
115void Game::button_release(int x, int y) {
116 int i;
117 ui.set_cursor (DEFAULTC);
118 if (state != PLAYING || grabbed == EMPTY)
119 return;
120 if (grabbed == BUCKET) {
121 grabbed = EMPTY;
122 for (i=0; i<net.ncables; i++)
123 if (net.cables[i].onspark(x, y)) {
124 net.cables[i].active=0;
125 net.cables[i].delay = spark.delay(level);
126 }
127 return;
128 }
129 for (i=0; i<net.units; i++)
130 if (net.computers[i].oncomputer(x, y)
131 &&
132 net.computers[i].compatible (bill.list[grabbed].cargo)
133 &&
134 (net.computers[i].os == OS.WINGDOWS ||
135 net.computers[i].os == OS.OFF))
136 {
137 net.base++;
138 if (net.computers[i].os == OS.WINGDOWS)
139 net.win--;
140 else
141 net.off--;
142 net.computers[i].os = bill.list[grabbed].cargo;
143 bill.list[grabbed].state = bill.list[grabbed].OFF;
144 grabbed = EMPTY;
145 return;
146 }
147 grabbed = EMPTY;
148 }
149
150void Game::update() {
151 switch (state) {
152 case PLAYING:
153 ui.clear();
154 bucket.draw();
155 net.update();
156 net.draw();
157 bill.update();
158 bill.draw();
159 update_info();
160 if (!(bill.on_screen+bill.off_screen)) {
161 update_score(ENDLEVEL);
162 state = BETWEEN;
163 }
164 if ((net.base+net.off)<=1) state = END;
165 break;
166 case END:
167 ui.clear();
168 net.toasters();
169 net.draw();
170 ui.refresh();
171 ui.popup_dialog(ENDGAME);
172 /* if (score > scores.score[9]) ui.popup_dialog(ENTERNAME);
173 scores.update();*/
174 ui.popup_dialog(HIGHSCORE);
175 ui.clear();
176 ui.draw_centered(logo);
177 ui.kill_timer();
178 ui.set_pausebutton (false);
179 state = WAITING;
180 break;
181 case BETWEEN:
182 ui.update_scorebox(level, score);
183 ui.popup_dialog (SCORE);
184 state = PLAYING;
185 setup_level(++level);
186 break;
187 }
188 ui.refresh();
189 iteration++;
190}
191
192void Game::main(int argc, char **argv) {
193 int c;
194 extern char *optarg;
195
196 level = 0;
197 ui.initialize(&argc, argv);
198 while (argv && argv[0] && (c = getopt(argc, argv, "l:L:")) != -1)
199 switch(c) {
200 case 'l':
201 case 'L': level = MAX (1, atoi(optarg)); break;
202 }
203 srand(time(NULL));
204 ui.make_mainwin();
205 ui.graph_init();
206 ui.clear();
207 logo.load("logo");
208 ui.draw_centered(logo);
209 ui.refresh();
210 ui.make_windows();
211 // scores.read();
212 // scores.update();
213
214 bill.load_pix();
215 OS.load_pix();
216 net.load_pix();
217 bucket.load_pix();
218 spark.load_pix();
219
220 ui.load_cursors();
221
222 state = WAITING;
223 if (level) start(level);
224 else ui.set_pausebutton(false);
225 ui.MainLoop();
226 exit(0);
227}
228
229int main(int argc, char **argv) {
230 if (argc>1 && !strcmp(argv[1], "-v")) {
231 printf ("XBill version 2.0\n\n");
232 exit(0);
233 }
234 if (argc>1 && !strcmp(argv[1], "-h")) {
235 printf ("XBill version 2.0\n");
236 printf ("Options:\n");
237 printf ("-l n, -L n\tStart at level n.\n");
238 printf ("-v\t\tPrint version number and exit.\n");
239 printf ("-h\t\tPrint help and exit.\n");
240 printf ("leaves the window.\n");
241 printf ("All standard X Intrinsics options are also ");
242 printf ("supported.\n\n");
243 exit(0);
244 }
245 game.main(argc, argv);
246}
diff --git a/noncore/games/kbill/Game.h b/noncore/games/kbill/Game.h
new file mode 100644
index 0000000..4473936
--- a/dev/null
+++ b/noncore/games/kbill/Game.h
@@ -0,0 +1,55 @@
1#ifndef GAME_H
2#define GAME_H
3
4#include "objects.h"
5
6class Game {
7 unsigned state;
8 int efficiency;
9public:
10 unsigned score, level, iteration;
11 Picture logo;
12 int grabbed;
13
14 static const unsigned short scrwidth = 240;
15 static const unsigned short scrheight = 290;
16
17 static const int PLAYING = 1;
18 static const int BETWEEN = 2;
19 static const int END = 3;
20 static const int WAITING = 4;
21
22 static const int DEFAULTC = 0; /* cursors */
23 static const int DOWNC = -1;
24 static const int BUCKETC = -2;
25
26 static const int ENDGAME = 200; /* dialog window IDs */
27 static const int ENTERNAME = 201;
28 static const int HIGHSCORE = 202;
29 static const int SCORE = 203;
30
31 static const int ENDLEVEL = -1; /* Codes for updating score */
32 static const int BILLPOINTS = 5;
33
34 static const int EMPTY = -2; /* Grabbed object */
35 static const int BUCKET = -1;
36
37 int RAND(int lb, int ub);
38 int MAX(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,
41 int h2);
42
43 void setup_level (unsigned int lev);
44 void start(unsigned int lev);
45 void quit();
46 void update_info();
47 void update_score (int action);
48 void warp_to_level (unsigned int lev);
49 void button_press(int x, int y);
50 void button_release(int x, int y);
51 void update();
52 void main(int argc, char **argv);
53};
54
55#endif
diff --git a/noncore/games/kbill/Horde.cc b/noncore/games/kbill/Horde.cc
new file mode 100644
index 0000000..d908037
--- a/dev/null
+++ b/noncore/games/kbill/Horde.cc
@@ -0,0 +1,64 @@
1#include "objects.h"
2
3void Horde::setup() {
4 for (int i=0; i < MAX_BILLS; i++)
5 list[i].state = list[i].OFF;
6 off_screen = on (game.level);
7 on_screen = 0;
8}
9
10/* Launches Bills whenever called */
11void Horde::launch(int max){
12 int i, n;
13 if (!max || !off_screen) return;
14 n=game.RAND(1, game.MIN(max, off_screen));
15 for (i=0; n; n--) {
16 for (i++; i < MAX_BILLS; i++)
17 if (list[i].state == list[i].OFF) break;
18 if (i == MAX_BILLS) return;
19 list[i++].enter();
20 }
21}
22
23int Horde::on (unsigned int lev) {
24 return game.MIN(8+3*lev, MAX_BILLS);
25}
26
27int Horde::max_at_once (unsigned int lev) {
28 return game.MIN(2+lev/4, 12);
29}
30
31int Horde::between (unsigned int lev) {
32 return game.MAX(14-lev/3, 10);
33}
34
35void Horde::load_pix () {
36 int i;
37 for (i=0; i < WCELS-1; i++) {
38 lcels[i].load("billL", i);
39 rcels[i].load("billR", i);
40 }
41 lcels[WCELS-1] = lcels[1];
42 rcels[WCELS-1] = rcels[1];
43
44 for (i=0; i < DCELS; i++)
45 dcels[i].load("billD", i);
46 width=dcels[0].width;
47 height=dcels[0].height;
48
49 for (i=0; i < ACELS; i++)
50 acels[i].load("billA", i);
51}
52
53void Horde::update() {
54 int i;
55 if (!(game.iteration % between(game.level)))
56 launch(max_at_once(game.level));
57 for (i=0; i < MAX_BILLS; i++) list[i].update();
58}
59
60void Horde::draw() {
61 int i;
62 for (i=0; i < MAX_BILLS; i++) list[i].draw();
63}
64
diff --git a/noncore/games/kbill/Horde.h b/noncore/games/kbill/Horde.h
new file mode 100644
index 0000000..a54a620
--- a/dev/null
+++ b/noncore/games/kbill/Horde.h
@@ -0,0 +1,27 @@
1#ifndef HORDE_H
2#define HORDE_H
3
4#include "Monster.h"
5#include "Picture.h"
6
7 class Horde { /*global structure of all bills*/
8public:
9 static const int MAX_BILLS = 100;/*max Bills per level*/
10 static const int WCELS = 4;/* # of bill walking animation frames*/
11 static const int DCELS = 5;/* # of bill dying animation frames*/
12 static const int ACELS = 13;/* # of bill switching OS frames*/
13 Monster list[MAX_BILLS];/* list of monsters in all states*/
14 int width, height;
15 int on_screen, off_screen;
16 Picture lcels[WCELS], rcels[WCELS], acels[ACELS], dcels[DCELS];
17 void load_pix();
18 void setup();
19 void launch(int max);
20 int on(unsigned int lev);
21 int max_at_once(unsigned int lev);
22 int between(unsigned int lev);
23 void update();
24 void draw();
25};
26
27#endif
diff --git a/noncore/games/kbill/Library.cc b/noncore/games/kbill/Library.cc
new file mode 100644
index 0000000..bb1e548
--- a/dev/null
+++ b/noncore/games/kbill/Library.cc
@@ -0,0 +1,13 @@
1#include "objects.h"
2
3void Library::load_pix() {
4 int i;
5 char *name[] = {"wingdows", "apple", "next", "sgi", "sun", "os2",
6 "bsd", "linux", "redhat", "hurd"};
7 for (i=0; i <= NUM_OS; i++) {
8 os[i].load(name[i]);
9 if (i) cursor[i].load(name[i], cursor[i].OWN_MASK);
10 }
11 width = os[0].width;
12 height = os[0].height;
13}
diff --git a/noncore/games/kbill/Library.h b/noncore/games/kbill/Library.h
new file mode 100644
index 0000000..eda2fcf
--- a/dev/null
+++ b/noncore/games/kbill/Library.h
@@ -0,0 +1,19 @@
1#ifndef LIBRARY_H
2#define LIBRARY_H
3
4#include "Picture.h"
5#include "MCursor.h"
6
7 class Library { /* global structure of all OSes */
8public:
9 static const int WINGDOWS = 0;/* OS 0 is wingdows */
10 static const int OFF = -1;/* OS -1 means the computer is off */
11 static const int PC = 5;/* OS >= PC means the OS is a PC OS */
12 static const int NUM_OS = 9;/* The number of OSes (not Wingdows) */
13 int width, height; /* size of OS picture*/
14 Picture os[NUM_OS+1]; /* array of OS pictures*/
15 MCursor cursor[NUM_OS+1];/* array of OS cursors (drag/drop) */
16 void load_pix();
17};
18
19#endif
diff --git a/noncore/games/kbill/MCursor.cc b/noncore/games/kbill/MCursor.cc
new file mode 100644
index 0000000..30f7577
--- a/dev/null
+++ b/noncore/games/kbill/MCursor.cc
@@ -0,0 +1,69 @@
1/***************************************************************************
2 MCursor.cc - description
3 -------------------
4 begin : Thu Dec 30 1999
5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
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 *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#include "MCursor.h"
18#include "objects.h"
19
20#include <qcursor.h>
21#include <qbitmap.h>
22#include <qwidget.h>
23#include <qstring.h>
24#ifdef KDEVER
25#include <kapp.h>
26#include <kstandarddirs.h>
27#endif
28#include <iostream.h>
29#include <qpe/resource.h>
30MCursor::~MCursor() {
31 delete cursor;
32}
33
34void MCursor::load(const char *name, int masked) {
35
36 #ifdef KDEVER
37 QString file, mfile;
38 KStandardDirs dirs;
39
40
41 file = dirs.findResource("data","kbill/bitmaps/" + QString::fromLocal8Bit(name) + ".xbm");
42
43 QBitmap bitmap, mask;
44 if (bitmap.load(file) == FALSE) {
45 cerr << "cannot open " << file << endl;
46 exit(1);
47 }
48 if (masked == SEP_MASK) {
49 // mfile.sprintf ("%sbitmaps/%s_mask.xbm", (const char*)dir, name);
50 mfile = file = dirs.findResource("data","kbill/bitmaps/" + QString::fromLocal8Bit(name) + "_mask.xbm");
51 if (mask.load(mfile) == FALSE) {
52 cerr << "cannot open " << file << endl;
53 exit(1);
54 }
55 }
56 else
57 mask = bitmap;
58 #endif
59
60 QBitmap bitmap, mask;
61 bitmap = Resource::loadBitmap("kbill/bitmaps/" + QString::fromLocal8Bit(name));
62
63 if (masked == SEP_MASK)
64 mask = bitmap = Resource::loadBitmap("kbill/bitmaps/" + QString::fromLocal8Bit(name) + "_mask.xbm");
65 else
66 mask = bitmap;
67 cursor = new QCursor(bitmap, mask, bitmap.width() / 2, bitmap.height() / 2);
68}
69
diff --git a/noncore/games/kbill/MCursor.h b/noncore/games/kbill/MCursor.h
new file mode 100644
index 0000000..5bf195e
--- a/dev/null
+++ b/noncore/games/kbill/MCursor.h
@@ -0,0 +1,37 @@
1/***************************************************************************
2 MCursor.h - description
3 -------------------
4 begin : Thu Dec 30 1999
5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
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 *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef MCURSOR_H
18#define MCURSOR_H
19
20/*#include <X11/Xlib.h>
21#include <X11/xpm.h>*/
22
23#include <qcursor.h>
24
25class MCursor {
26public:
27 ~MCursor();
28 static const int SEP_MASK = 0;
29 static const int OWN_MASK = 1;
30 void load(const char *name, int masked);
31private:
32 QCursor *cursor;
33
34 friend class UI;
35};
36
37#endif
diff --git a/noncore/games/kbill/Makefile b/noncore/games/kbill/Makefile
new file mode 100644
index 0000000..419aaaf
--- a/dev/null
+++ b/noncore/games/kbill/Makefile
@@ -0,0 +1,533 @@
1#############################################################################
2# Automatically generated from kbill/Makefile.in
3# Build options from
4#############################################################################
5
6# Compiling
7 INTERFACE_DECL_PATH = .
8 SYSCONF_CXX = g++
9 SYSCONF_CC = gcc
10 DASHCROSS =
11
12# Compiling with support libraries
13 SYSCONF_CXXFLAGS_X11=
14 SYSCONF_CXXFLAGS_QT= -I$(QTDIR)/include
15 SYSCONF_CXXFLAGS_OPENGL= -I/usr/X11R6/include
16
17# Compiling YACC output
18SYSCONF_CXXFLAGS_YACC = -Wno-unused -Wno-parentheses
19
20# Linking with support libraries
21 SYSCONF_RPATH_X11=
22 SYSCONF_RPATH_QT= -Wl,-rpath,$(QTDIR)/lib
23 SYSCONF_RPATH_OPENGL= -Wl,-rpath,/usr/X11R6/lib
24
25# Linking with support libraries
26# X11
27 SYSCONF_LFLAGS_X11=
28 SYSCONF_LIBS_X11=
29# Qt, Qt+OpenGL
30 SYSCONF_LFLAGS_QT= -L$(QTDIR)/lib
31 SYSCONF_LIBS_QT = -lqte$(QT_THREAD_SUFFIX)
32 SYSCONF_LIBS_QT_OPENGL=
33# OpenGL
34 SYSCONF_LFLAGS_OPENGL= -L/usr/X11R6/lib
35 SYSCONF_LIBS_OPENGL=
36# Yacc
37 SYSCONF_LIBS_YACC=
38
39# Linking applications
40 SYSCONF_LINK = gcc
41 SYSCONF_LFLAGS =
42 SYSCONF_LIBS =
43
44# Link flags for shared objects
45 SYSCONF_LFLAGS_SHOBJ= -shared
46
47# Flags for threading
48 SYSCONF_CFLAGS_THREAD= -D_REENTRANT
49 SYSCONF_CXXFLAGS_THREAD= -D_REENTRANT
50 SYSCONF_LFLAGS_THREAD=
51 SYSCONF_LIBS_THREAD= -lpthread
52
53# Meta-object compiler
54 SYSCONF_MOC = $(QTDIR)/bin/moc
55
56# UI compiler
57 SYSCONF_UIC = $(QTDIR)/bin/uic
58
59# Linking shared libraries
60# - Build the $(TARGET) library, eg. lib$(TARGET).so.2.2.2
61# - Place target in $(DESTDIR) - which has a trailing /
62# - Usually needs to incorporate $(VER_MAJ), $(VER_MIN) and $(VER_PATCH)
63#
64 SYSCONF_LINK_SHLIB= gcc
65 SYSCONF_LINK_TARGET_SHARED= lib$(TARGET).so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH)
66 SYSCONF_LINK_LIB_SHARED= $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \
67 $(LFLAGS) -o $(SYSCONF_LINK_TARGET_SHARED) \
68 $(OBJECTS) $(OBJMOC) $(LIBS) && \
69 mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \
70 cd $(DESTDIR) && \
71 rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN); \
72 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \
73 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ); \
74 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN)
75
76# Linking static libraries
77# - Build the $(TARGET) library, eg. lib$(TARGET).a
78# - Place target in $(DESTDIR) - which has a trailing /
79#
80 SYSCONF_AR = ar cqs
81SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a
82 SYSCONF_LINK_LIB_STATIC= rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \
83 $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) $(OBJMOC)
84# Compiling application source
85 SYSCONF_CXXFLAGS= -pipe -DQWS -fno-exceptions -fno-rtti -O2 -Wall -W
86 SYSCONF_CFLAGS = -pipe -O2 -Wall -W
87# Default link type (static linking is still be used where required)
88 SYSCONF_LINK_LIB= $(SYSCONF_LINK_LIB_SHARED)
89 SYSCONF_LINK_TARGET= $(SYSCONF_LINK_TARGET_SHARED)
90# Compiling library source
91 SYSCONF_CXXFLAGS_LIB= -fPIC
92 SYSCONF_CFLAGS_LIB= -fPIC
93# Compiling shared-object source
94 SYSCONF_CXXFLAGS_SHOBJ= -fPIC
95 SYSCONF_CFLAGS_SHOBJ= -fPIC
96# Linking Qt
97 SYSCONF_LIBS_QTLIB= $(SYSCONF_LFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT)
98# Linking Qt applications
99 SYSCONF_LIBS_QTAPP=
100#############################################################################
101
102####### Compiler, tools and options
103
104 CXX =$(SYSCONF_CXX) $(QT_CXX_MT)
105 CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS)
106 CC =$(SYSCONF_CC) $(QT_C_MT)
107 CFLAGS =$(SYSCONF_CFLAGS)
108 INCPATH =-I$(OPIEDIR)/include
109 LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT)
110 LIBS =$(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP)
111 MOC =$(SYSCONF_MOC)
112 UIC =$(SYSCONF_UIC)
113
114####### Target
115
116DESTDIR = $(OPIEDIR)/bin/
117VER_MAJ = 1
118VER_MIN = 0
119VER_PATCH = 0
120 TARGET= zBill
121TARGET1 = lib$(TARGET).so.$(VER_MAJ)
122
123####### Files
124
125 HEADERS =kbill.h \
126 field.h \
127 Bucket.h \
128 Cable.h \
129 Computer.h \
130 Game.h \
131 Horde.h \
132 Library.h \
133 MCursor.h \
134 Monster.h \
135 Network.h \
136 Picture.h \
137 Spark.h \
138 Strings.h \
139 UI.h \
140 objects.h \
141 inputbox.h
142 SOURCES =field.cpp \
143 Bucket.cc \
144 Cable.cc \
145 Computer.cc \
146 Game.cc \
147 Horde.cc \
148 Library.cc \
149 MCursor.cc \
150 Monster.cc \
151 Network.cc \
152 Picture.cc \
153 Spark.cc \
154 UI.cpp \
155 inputbox.cpp \
156 kbill.cpp
157 OBJECTS =field.o \
158 Bucket.o \
159 Cable.o \
160 Computer.o \
161 Game.o \
162 Horde.o \
163 Library.o \
164 MCursor.o \
165 Monster.o \
166 Network.o \
167 Picture.o \
168 Spark.o \
169 UI.o \
170 inputbox.o \
171 kbill.o
172INTERFACES =
173UICDECLS =
174UICIMPLS =
175 SRCMOC =moc_kbill.cpp \
176 moc_field.cpp \
177 moc_inputbox.cpp
178 OBJMOC =moc_kbill.o \
179 moc_field.o \
180 moc_inputbox.o
181
182
183####### Implicit rules
184
185.SUFFIXES: .cpp .cxx .cc .C .c
186
187.cpp.o:
188 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
189
190.cxx.o:
191 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
192
193.cc.o:
194 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
195
196.C.o:
197 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
198
199.c.o:
200 $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
201
202####### Build rules
203
204
205all: $(DESTDIR)$(TARGET)
206
207$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS)
208 $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
209
210moc: $(SRCMOC)
211
212tmake:
213 tmake kbill.pro
214
215clean:
216 -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS)
217 -rm -f *~ core
218 -rm -f allmoc.cpp
219
220####### Extension Modules
221
222listpromodules:
223 @echo
224
225listallmodules:
226 @echo
227
228listaddonpromodules:
229 @echo
230
231listaddonentmodules:
232 @echo
233
234
235REQUIRES=
236
237####### Sub-libraries
238
239
240###### Combined headers
241
242
243
244####### Compile
245
246field.o: field.cpp \
247 objects.h \
248 Horde.h \
249 Monster.h \
250 Picture.h \
251 Network.h \
252 Computer.h \
253 Cable.h \
254 Library.h \
255 MCursor.h \
256 Bucket.h \
257 Spark.h \
258 Game.h \
259 UI.h \
260 $(OPIEDIR)/include/qpe/qpeapplication.h \
261 field.h \
262 kbill.h
263
264Bucket.o: Bucket.cc \
265 objects.h \
266 Horde.h \
267 Monster.h \
268 Picture.h \
269 Network.h \
270 Computer.h \
271 Cable.h \
272 Library.h \
273 MCursor.h \
274 Bucket.h \
275 Spark.h \
276 Game.h \
277 UI.h \
278 $(OPIEDIR)/include/qpe/qpeapplication.h \
279 field.h \
280 kbill.h
281
282Cable.o: Cable.cc \
283 objects.h \
284 Horde.h \
285 Monster.h \
286 Picture.h \
287 Network.h \
288 Computer.h \
289 Cable.h \
290 Library.h \
291 MCursor.h \
292 Bucket.h \
293 Spark.h \
294 Game.h \
295 UI.h \
296 $(OPIEDIR)/include/qpe/qpeapplication.h \
297 field.h \
298 kbill.h
299
300Computer.o: Computer.cc \
301 objects.h \
302 Horde.h \
303 Monster.h \
304 Picture.h \
305 Network.h \
306 Computer.h \
307 Cable.h \
308 Library.h \
309 MCursor.h \
310 Bucket.h \
311 Spark.h \
312 Game.h \
313 UI.h \
314 $(OPIEDIR)/include/qpe/qpeapplication.h \
315 field.h \
316 kbill.h
317
318Game.o: Game.cc \
319 objects.h \
320 Horde.h \
321 Monster.h \
322 Picture.h \
323 Network.h \
324 Computer.h \
325 Cable.h \
326 Library.h \
327 MCursor.h \
328 Bucket.h \
329 Spark.h \
330 Game.h \
331 UI.h \
332 $(OPIEDIR)/include/qpe/qpeapplication.h \
333 field.h \
334 kbill.h
335
336Horde.o: Horde.cc \
337 objects.h \
338 Horde.h \
339 Monster.h \
340 Picture.h \
341 Network.h \
342 Computer.h \
343 Cable.h \
344 Library.h \
345 MCursor.h \
346 Bucket.h \
347 Spark.h \
348 Game.h \
349 UI.h \
350 $(OPIEDIR)/include/qpe/qpeapplication.h \
351 field.h \
352 kbill.h
353
354Library.o: Library.cc \
355 objects.h \
356 Horde.h \
357 Monster.h \
358 Picture.h \
359 Network.h \
360 Computer.h \
361 Cable.h \
362 Library.h \
363 MCursor.h \
364 Bucket.h \
365 Spark.h \
366 Game.h \
367 UI.h \
368 $(OPIEDIR)/include/qpe/qpeapplication.h \
369 field.h \
370 kbill.h
371
372MCursor.o: MCursor.cc \
373 MCursor.h \
374 objects.h \
375 Horde.h \
376 Monster.h \
377 Picture.h \
378 Network.h \
379 Computer.h \
380 Cable.h \
381 Library.h \
382 Bucket.h \
383 Spark.h \
384 Game.h \
385 UI.h \
386 $(OPIEDIR)/include/qpe/qpeapplication.h \
387 field.h \
388 kbill.h \
389 $(OPIEDIR)/include/qpe/resource.h
390
391Monster.o: Monster.cc \
392 objects.h \
393 Horde.h \
394 Monster.h \
395 Picture.h \
396 Network.h \
397 Computer.h \
398 Cable.h \
399 Library.h \
400 MCursor.h \
401 Bucket.h \
402 Spark.h \
403 Game.h \
404 UI.h \
405 $(OPIEDIR)/include/qpe/qpeapplication.h \
406 field.h \
407 kbill.h
408
409Network.o: Network.cc \
410 objects.h \
411 Horde.h \
412 Monster.h \
413 Picture.h \
414 Network.h \
415 Computer.h \
416 Cable.h \
417 Library.h \
418 MCursor.h \
419 Bucket.h \
420 Spark.h \
421 Game.h \
422 UI.h \
423 $(OPIEDIR)/include/qpe/qpeapplication.h \
424 field.h \
425 kbill.h
426
427Picture.o: Picture.cc \
428 Picture.h \
429 objects.h \
430 Horde.h \
431 Monster.h \
432 Network.h \
433 Computer.h \
434 Cable.h \
435 Library.h \
436 MCursor.h \
437 Bucket.h \
438 Spark.h \
439 Game.h \
440 UI.h \
441 $(OPIEDIR)/include/qpe/qpeapplication.h \
442 field.h \
443 kbill.h \
444 $(OPIEDIR)/include/qpe/resource.h
445
446Spark.o: Spark.cc \
447 objects.h \
448 Horde.h \
449 Monster.h \
450 Picture.h \
451 Network.h \
452 Computer.h \
453 Cable.h \
454 Library.h \
455 MCursor.h \
456 Bucket.h \
457 Spark.h \
458 Game.h \
459 UI.h \
460 $(OPIEDIR)/include/qpe/qpeapplication.h \
461 field.h \
462 kbill.h
463
464UI.o: UI.cpp \
465 kbill.h \
466 field.h \
467 objects.h \
468 Horde.h \
469 Monster.h \
470 Picture.h \
471 Network.h \
472 Computer.h \
473 Cable.h \
474 Library.h \
475 MCursor.h \
476 Bucket.h \
477 Spark.h \
478 Game.h \
479 UI.h \
480 $(OPIEDIR)/include/qpe/qpeapplication.h \
481 Strings.h \
482 inputbox.h
483
484inputbox.o: inputbox.cpp \
485 inputbox.h
486
487kbill.o: kbill.cpp \
488 kbill.h \
489 field.h \
490 inputbox.h \
491 objects.h \
492 Horde.h \
493 Monster.h \
494 Picture.h \
495 Network.h \
496 Computer.h \
497 Cable.h \
498 Library.h \
499 MCursor.h \
500 Bucket.h \
501 Spark.h \
502 Game.h \
503 UI.h \
504 $(OPIEDIR)/include/qpe/qpeapplication.h \
505 Strings.h
506
507moc_kbill.o: moc_kbill.cpp \
508 kbill.h \
509 field.h
510
511moc_field.o: moc_field.cpp \
512 field.h
513
514moc_inputbox.o: moc_inputbox.cpp \
515 inputbox.h
516
517moc_kbill.cpp: kbill.h
518 $(MOC) kbill.h -o moc_kbill.cpp
519
520moc_field.cpp: field.h
521 $(MOC) field.h -o moc_field.cpp
522
523moc_inputbox.cpp: inputbox.h
524 $(MOC) inputbox.h -o moc_inputbox.cpp
525
526
527
528lupdate:
529 lupdate kbill.pro
530
531lrelease:
532 lrelease kbill.pro
533
diff --git a/noncore/games/kbill/Makefile.am b/noncore/games/kbill/Makefile.am
new file mode 100644
index 0000000..a09ea13
--- a/dev/null
+++ b/noncore/games/kbill/Makefile.am
@@ -0,0 +1,59 @@
1####### kdevelop will overwrite this part!!! (begin)##########
2bin_PROGRAMS = kbill
3kbill_SOURCES = inputbox.cpp UI.cc Spark.cc Scorelist.cc Picture.cc Network.cc Monster.cc MCursor.cc Library.cc Horde.cc Game.cc Computer.cc Cable.cc Bucket.cc field.cpp kbill.cpp
4kbill_LDADD = $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) $(LIBSOCKET) $(LIB_KIO)
5
6
7SUBDIRS = docs bitmaps pixmaps
8
9EXTRA_DIST = kbill.cpp kbill.h kbill.kdelnk kbill.xpm mini-kbill.xpm field.cpp field.h Bucket.cc Bucket.h Cable.cc Cable.h Computer.cc Computer.h Game.cc Game.h Horde.cc Horde.h Library.cc Library.h MCursor.cc MCursor.h Monster.cc \ Monster.h Network.cc Network.h Picture.cc Picture.h Scorelist.cc Scorelist.h Spark.cc Spark.h \ Strings.h UI.cc objects.h inputbox.cpp inputbox.h
10
11install-data-local:
12 $(mkinstalldirs) $(kde_appsdir)/Games/
13 $(INSTALL_DATA) kbill.kdelnk $(kde_appsdir)/Games/kbill.kdelnk
14 $(mkinstalldirs) $(kde_icondir)/
15 $(INSTALL_DATA) kbill.xpm $(kde_icondir)/kbill.xpm
16 $(mkinstalldirs) $(kde_minidir)/
17 $(INSTALL_DATA) mini-kbill.xpm $(kde_minidir)/kbill.xpm
18 $(mkinstalldirs) $(kde_datadir)/kbill/
19 $(INSTALL_DATA) scores $(kde_datadir)/kbill/scores
20
21uninstall-local:
22 -rm -f $(kde_appsdir)/Games/kbill.kdelnk
23 -rm -f $(kde_icondir)/kbill.xpm
24 -rm -f $(kde_minidir)/kbill.xpm
25 -rm -f $(kde_datadir)/kbill/scores
26
27####### kdevelop will overwrite this part!!! (end)############
28# this 10 paths are KDE specific. Use them:
29# kde_htmldir Where your docs should go to. (contains lang subdirs)
30# kde_appsdir Where your application file (.kdelnk) should go to.
31# kde_icondir Where your icon should go to.
32# kde_minidir Where your mini icon should go to.
33# kde_datadir Where you install application data. (Use a subdir)
34# kde_locale Where translation files should go to.(contains lang subdirs)
35# kde_cgidir Where cgi-bin executables should go to.
36# kde_confdir Where config files should go to.
37# kde_mimedir Where mimetypes should go to.
38# kde_toolbardir Where general toolbar icons should go to.
39# kde_wallpaperdir Where general wallpapers should go to.
40
41# set the include path for X, qt and KDE
42INCLUDES= $(all_includes)
43# claim, which subdirectories you want to install
44# you can add here more. This one gets installed
45bin_PROGRAMS = kbill
46
47kbill_METASOURCES = USE_AUTOMOC
48
49# the library search path.
50kbill_LDFLAGS = $(all_libraries) $(KDE_RPATH)
51
52# them while "make clean", use CLEANFILES
53DISTCLEANFILES = $(kbill_METASOURCES)
54
55# make messages.po. Move this one to ../po/ and "make merge" in po
56# the -x is for skipping messages already translated in kdelibs
57messages:
58 $(XGETTEXT) -C -ki18n -x $(KDEDIR)/include/kde.pot `find . -name \*.h -o -name \*.cpp -o -name \*.cc` -o ../po/kbill.pot
59
diff --git a/noncore/games/kbill/Makefile.in b/noncore/games/kbill/Makefile.in
new file mode 100644
index 0000000..281db16
--- a/dev/null
+++ b/noncore/games/kbill/Makefile.in
@@ -0,0 +1,427 @@
1#############################################################################
2
3####### Compiler, tools and options
4
5 CXX =$(SYSCONF_CXX) $(QT_CXX_MT)
6 CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS)
7 CC =$(SYSCONF_CC) $(QT_C_MT)
8 CFLAGS =$(SYSCONF_CFLAGS)
9 INCPATH =-I$(OPIEDIR)/include
10 LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT)
11 LIBS =$(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP)
12 MOC =$(SYSCONF_MOC)
13 UIC =$(SYSCONF_UIC)
14
15####### Target
16
17DESTDIR = $(OPIEDIR)/bin/
18VER_MAJ = 1
19VER_MIN = 0
20VER_PATCH = 0
21 TARGET= zBill
22TARGET1 = lib$(TARGET).so.$(VER_MAJ)
23
24####### Files
25
26 HEADERS =kbill.h \
27 field.h \
28 Bucket.h \
29 Cable.h \
30 Computer.h \
31 Game.h \
32 Horde.h \
33 Library.h \
34 MCursor.h \
35 Monster.h \
36 Network.h \
37 Picture.h \
38 Spark.h \
39 Strings.h \
40 UI.h \
41 objects.h \
42 inputbox.h
43 SOURCES =field.cpp \
44 Bucket.cc \
45 Cable.cc \
46 Computer.cc \
47 Game.cc \
48 Horde.cc \
49 Library.cc \
50 MCursor.cc \
51 Monster.cc \
52 Network.cc \
53 Picture.cc \
54 Spark.cc \
55 UI.cpp \
56 inputbox.cpp \
57 kbill.cpp
58 OBJECTS =field.o \
59 Bucket.o \
60 Cable.o \
61 Computer.o \
62 Game.o \
63 Horde.o \
64 Library.o \
65 MCursor.o \
66 Monster.o \
67 Network.o \
68 Picture.o \
69 Spark.o \
70 UI.o \
71 inputbox.o \
72 kbill.o
73INTERFACES =
74UICDECLS =
75UICIMPLS =
76 SRCMOC =moc_kbill.cpp \
77 moc_field.cpp \
78 moc_inputbox.cpp
79 OBJMOC =moc_kbill.o \
80 moc_field.o \
81 moc_inputbox.o
82
83
84####### Implicit rules
85
86.SUFFIXES: .cpp .cxx .cc .C .c
87
88.cpp.o:
89 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
90
91.cxx.o:
92 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
93
94.cc.o:
95 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
96
97.C.o:
98 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
99
100.c.o:
101 $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
102
103####### Build rules
104
105
106all: $(DESTDIR)$(TARGET)
107
108$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS)
109 $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
110
111moc: $(SRCMOC)
112
113tmake:
114 tmake kbill.pro
115
116clean:
117 -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS)
118 -rm -f *~ core
119 -rm -f allmoc.cpp
120
121####### Extension Modules
122
123listpromodules:
124 @echo
125
126listallmodules:
127 @echo
128
129listaddonpromodules:
130 @echo
131
132listaddonentmodules:
133 @echo
134
135
136REQUIRES=
137
138####### Sub-libraries
139
140
141###### Combined headers
142
143
144
145####### Compile
146
147field.o: field.cpp \
148 objects.h \
149 Horde.h \
150 Monster.h \
151 Picture.h \
152 Network.h \
153 Computer.h \
154 Cable.h \
155 Library.h \
156 MCursor.h \
157 Bucket.h \
158 Spark.h \
159 Game.h \
160 UI.h \
161 $(OPIEDIR)/include/qpe/qpeapplication.h \
162 field.h \
163 kbill.h
164
165Bucket.o: Bucket.cc \
166 objects.h \
167 Horde.h \
168 Monster.h \
169 Picture.h \
170 Network.h \
171 Computer.h \
172 Cable.h \
173 Library.h \
174 MCursor.h \
175 Bucket.h \
176 Spark.h \
177 Game.h \
178 UI.h \
179 $(OPIEDIR)/include/qpe/qpeapplication.h \
180 field.h \
181 kbill.h
182
183Cable.o: Cable.cc \
184 objects.h \
185 Horde.h \
186 Monster.h \
187 Picture.h \
188 Network.h \
189 Computer.h \
190 Cable.h \
191 Library.h \
192 MCursor.h \
193 Bucket.h \
194 Spark.h \
195 Game.h \
196 UI.h \
197 $(OPIEDIR)/include/qpe/qpeapplication.h \
198 field.h \
199 kbill.h
200
201Computer.o: Computer.cc \
202 objects.h \
203 Horde.h \
204 Monster.h \
205 Picture.h \
206 Network.h \
207 Computer.h \
208 Cable.h \
209 Library.h \
210 MCursor.h \
211 Bucket.h \
212 Spark.h \
213 Game.h \
214 UI.h \
215 $(OPIEDIR)/include/qpe/qpeapplication.h \
216 field.h \
217 kbill.h
218
219Game.o: Game.cc \
220 objects.h \
221 Horde.h \
222 Monster.h \
223 Picture.h \
224 Network.h \
225 Computer.h \
226 Cable.h \
227 Library.h \
228 MCursor.h \
229 Bucket.h \
230 Spark.h \
231 Game.h \
232 UI.h \
233 $(OPIEDIR)/include/qpe/qpeapplication.h \
234 field.h \
235 kbill.h
236
237Horde.o: Horde.cc \
238 objects.h \
239 Horde.h \
240 Monster.h \
241 Picture.h \
242 Network.h \
243 Computer.h \
244 Cable.h \
245 Library.h \
246 MCursor.h \
247 Bucket.h \
248 Spark.h \
249 Game.h \
250 UI.h \
251 $(OPIEDIR)/include/qpe/qpeapplication.h \
252 field.h \
253 kbill.h
254
255Library.o: Library.cc \
256 objects.h \
257 Horde.h \
258 Monster.h \
259 Picture.h \
260 Network.h \
261 Computer.h \
262 Cable.h \
263 Library.h \
264 MCursor.h \
265 Bucket.h \
266 Spark.h \
267 Game.h \
268 UI.h \
269 $(OPIEDIR)/include/qpe/qpeapplication.h \
270 field.h \
271 kbill.h
272
273MCursor.o: MCursor.cc \
274 MCursor.h \
275 objects.h \
276 Horde.h \
277 Monster.h \
278 Picture.h \
279 Network.h \
280 Computer.h \
281 Cable.h \
282 Library.h \
283 Bucket.h \
284 Spark.h \
285 Game.h \
286 UI.h \
287 $(OPIEDIR)/include/qpe/qpeapplication.h \
288 field.h \
289 kbill.h \
290 $(OPIEDIR)/include/qpe/resource.h
291
292Monster.o: Monster.cc \
293 objects.h \
294 Horde.h \
295 Monster.h \
296 Picture.h \
297 Network.h \
298 Computer.h \
299 Cable.h \
300 Library.h \
301 MCursor.h \
302 Bucket.h \
303 Spark.h \
304 Game.h \
305 UI.h \
306 $(OPIEDIR)/include/qpe/qpeapplication.h \
307 field.h \
308 kbill.h
309
310Network.o: Network.cc \
311 objects.h \
312 Horde.h \
313 Monster.h \
314 Picture.h \
315 Network.h \
316 Computer.h \
317 Cable.h \
318 Library.h \
319 MCursor.h \
320 Bucket.h \
321 Spark.h \
322 Game.h \
323 UI.h \
324 $(OPIEDIR)/include/qpe/qpeapplication.h \
325 field.h \
326 kbill.h
327
328Picture.o: Picture.cc \
329 Picture.h \
330 objects.h \
331 Horde.h \
332 Monster.h \
333 Network.h \
334 Computer.h \
335 Cable.h \
336 Library.h \
337 MCursor.h \
338 Bucket.h \
339 Spark.h \
340 Game.h \
341 UI.h \
342 $(OPIEDIR)/include/qpe/qpeapplication.h \
343 field.h \
344 kbill.h \
345 $(OPIEDIR)/include/qpe/resource.h
346
347Spark.o: Spark.cc \
348 objects.h \
349 Horde.h \
350 Monster.h \
351 Picture.h \
352 Network.h \
353 Computer.h \
354 Cable.h \
355 Library.h \
356 MCursor.h \
357 Bucket.h \
358 Spark.h \
359 Game.h \
360 UI.h \
361 $(OPIEDIR)/include/qpe/qpeapplication.h \
362 field.h \
363 kbill.h
364
365UI.o: UI.cpp \
366 kbill.h \
367 field.h \
368 objects.h \
369 Horde.h \
370 Monster.h \
371 Picture.h \
372 Network.h \
373 Computer.h \
374 Cable.h \
375 Library.h \
376 MCursor.h \
377 Bucket.h \
378 Spark.h \
379 Game.h \
380 UI.h \
381 $(OPIEDIR)/include/qpe/qpeapplication.h \
382 Strings.h \
383 inputbox.h
384
385inputbox.o: inputbox.cpp \
386 inputbox.h
387
388kbill.o: kbill.cpp \
389 kbill.h \
390 field.h \
391 inputbox.h \
392 objects.h \
393 Horde.h \
394 Monster.h \
395 Picture.h \
396 Network.h \
397 Computer.h \
398 Cable.h \
399 Library.h \
400 MCursor.h \
401 Bucket.h \
402 Spark.h \
403 Game.h \
404 UI.h \
405 $(OPIEDIR)/include/qpe/qpeapplication.h \
406 Strings.h
407
408moc_kbill.o: moc_kbill.cpp \
409 kbill.h \
410 field.h
411
412moc_field.o: moc_field.cpp \
413 field.h
414
415moc_inputbox.o: moc_inputbox.cpp \
416 inputbox.h
417
418moc_kbill.cpp: kbill.h
419 $(MOC) kbill.h -o moc_kbill.cpp
420
421moc_field.cpp: field.h
422 $(MOC) field.h -o moc_field.cpp
423
424moc_inputbox.cpp: inputbox.h
425 $(MOC) inputbox.h -o moc_inputbox.cpp
426
427
diff --git a/noncore/games/kbill/Monster.cc b/noncore/games/kbill/Monster.cc
new file mode 100644
index 0000000..72bf39b
--- a/dev/null
+++ b/noncore/games/kbill/Monster.cc
@@ -0,0 +1,226 @@
1#include "objects.h"
2
3void Monster::get_border() {
4 int i=game.RAND(0,3);
5 if (i%2==0) target_x=game.RAND(0, game.scrwidth-bill.width);
6 else target_y=game.RAND(0, game.scrheight-bill.height);
7 switch (i) {
8 case 0: target_y=-bill.height-16; break;
9 case 1: target_x=game.scrwidth+1; break;
10 case 2: target_y=game.scrwidth+1; break;
11 case 3: target_x=-bill.width-2; break;
12 }
13}
14
15/* Adds a bill to the in state*/
16void Monster::enter(){
17 state = IN;
18 get_border();
19 x = target_x; y=target_y;
20 index = 0;
21 cels = bill.lcels;
22 cargo = OS.WINGDOWS;
23 x_offset = -2;
24 y_offset = -15;
25 target_c = game.RAND(0, net.units-1);
26 target_x = net.computers[target_c].x+net.width-XOFFSET;
27 target_y = net.computers[target_c].y+YOFFSET;
28 bill.on_screen++; bill.off_screen--;
29}
30
31/* Moves bill toward his target - returns whether or not he moved */
32int Monster::move (int mode) {
33 int xdist = target_x - x;
34 int ydist = target_y - y;
35 int step = step_size(game.level);
36 int dx, dy;
37 int signx = xdist >= 0 ? 1 : -1;
38 int signy = ydist >= 0 ? 1 : -1;
39 xdist = abs(xdist);
40 ydist = abs(ydist);
41 if (!xdist && !ydist) return 0;
42 else if (xdist<step && ydist<step) {
43 x = target_x;
44 y = target_y;
45 }
46 else {
47 dx = (xdist*step*signx)/(xdist+ydist);
48 dy = (ydist*step*signy)/(xdist+ydist);
49 switch(mode) {
50 case SLOW: break;
51 case FAST: dx = 5*dx/4; dy = 5*dy/4; break;
52 }
53 x+=dx;
54 y+=dy;
55 if (dx<0)
56 cels = bill.lcels;
57 else if (dx>0)
58 cels = bill.rcels;
59 }
60 return 1;
61}
62
63void Monster::draw() {
64 switch (state) {
65 case IN:
66 case OUT:
67 case DYING: draw_std(); break;
68 case AT: draw_at(); break;
69 case STRAY: draw_stray(); break;
70 default: break;
71 }
72}
73
74 /* Update Bill's position */
75void Monster::update_in() {
76 int moved = move(SLOW);
77 if (!moved && (net.computers[target_c].os != OS.WINGDOWS)
78 && !(net.computers[target_c].busy))
79 {
80 net.computers[target_c].busy=1;
81 cels = bill.acels;
82 index=0;
83 state = AT;
84 return;
85 }
86 else if (!moved) {
87 int i;
88 do {
89 i=game.RAND(0, net.units-1);
90 } while (i == target_c);
91 target_c = i;
92 target_x = net.computers[target_c].x + net.width-XOFFSET;
93 target_y = net.computers[target_c].y + YOFFSET;
94 }
95 index++;
96 index%=bill.WCELS;
97 y_offset+=(8*(index%2)-4);
98}
99
100/* Update Bill standing at a computer */
101void Monster::update_at() {
102 int sys;
103 if (index==0 && net.computers[target_c].os == OS.OFF) {
104 index=6;
105 sys = net.computers[target_c].find_stray();
106 if (sys<0) cargo = -1;
107 else {
108 cargo = bill.list[sys].cargo;
109 bill.list[sys].state = OFF;
110 }
111 }
112 else index++;
113 if (index == 13) {
114 y_offset = -15;
115 x_offset = -2;
116 get_border();
117 index = 0;
118 cels = bill.lcels;
119 state = OUT;
120 net.computers[target_c].busy=0;
121 return;
122 }
123 y_offset = bill.height - OS.height;
124 switch (index) {
125 case 1 :
126 case 2 : x -= 8; x_offset +=8; break;
127 case 3 : x -= 10; x_offset +=10; break;
128 case 4 : x += 3; x_offset -=3; break;
129 case 5 : x += 2; x_offset -=2; break;
130 case 6 :
131 if (net.computers[target_c].os != OS.OFF) {
132 net.base--; net.off++;
133 cargo = net.computers[target_c].os;
134 }
135 else {
136 x-=21; x_offset+=21;
137 }
138 net.computers[target_c].os = OS.OFF;
139 y_offset = -15;
140 x += 20;
141 x_offset -=20;
142 break;
143 case 7 : sy = y_offset; sx = -2; break;
144 case 8 : sy = -15; sx = -2; break;
145 case 9 : sy = -7; sx = -7; x -= 8; x_offset +=8; break;
146 case 10 : sy = 0; sx = -7; x -= 15; x_offset +=15; break;
147 case 11 : sy = 0; sx = -7;
148 net.computers[target_c].os = OS.WINGDOWS;
149 net.off--; net.win++;
150 break;
151 case 12 : x += 11; x_offset -=11;
152 }
153}
154
155/* Updates Bill fleeing with his ill gotten gain */
156void Monster::update_out() {
157 if (game.INTERSECT(x, y, bill.width, bill.height, 0, 0, game.scrwidth,
158 game.scrheight))
159 {
160 move(FAST);
161 index++;
162 index%=bill.WCELS;
163 y_offset+=(8*(index%2)-4);
164 }
165 else {
166 state = OFF;
167 bill.on_screen--; bill.off_screen++;
168 }
169}
170
171
172/* Updates Bill who is dying */
173void Monster::update_dying() {
174 if (index < bill.DCELS-1){
175 y_offset += (index*GRAVITY);
176 index++;
177 }
178 else {
179 y+=y_offset;
180 if (cargo<0 || cargo == OS.WINGDOWS) state = OFF;
181 else state = STRAY;
182 bill.on_screen--;
183 }
184}
185
186void Monster::update() {
187 switch (state) {
188 case IN: update_in(); break;
189 case AT: update_at(); break;
190 case OUT: update_out(); break;
191 case DYING: update_dying(); break;
192 default: break;
193 }
194}
195
196int Monster::clicked(int locx, int locy) {
197 return (locx>x && locx<x+bill.width && locy>y && locy<y+bill.height);
198}
199
200int Monster::clickedstray(int locx, int locy) {
201 return (locx>x && locx<x+OS.width && locy>y && locy<y+OS.height);
202}
203
204int Monster::step_size(unsigned int lev) {
205 return game.MIN(14+lev, 18);
206}
207
208void Monster::draw_std() {
209 if (cargo>=0)
210 ui.draw(OS.os[cargo], x + x_offset, y + y_offset);
211 ui.draw(cels[index], x, y);
212}
213
214void Monster::draw_at() {
215 if (index>6 && index<12)
216 ui.draw(OS.os[0], x + sx, y + sy);
217 if (cargo>=0)
218 ui.draw(OS.os[cargo], x + x_offset, y + y_offset);
219 ui.draw(cels[index], net.computers[target_c].x,
220 net.computers[target_c].y);
221}
222
223void Monster::draw_stray() {
224 if (game.grabbed==-1 || x != bill.list[game.grabbed].x)
225 ui.draw(OS.os[cargo], x, y);
226}
diff --git a/noncore/games/kbill/Monster.h b/noncore/games/kbill/Monster.h
new file mode 100644
index 0000000..84a8961
--- a/dev/null
+++ b/noncore/games/kbill/Monster.h
@@ -0,0 +1,53 @@
1#ifndef BILL_H
2#define BILL_H
3
4#include "Picture.h"
5
6 class Monster { /*structure for Bills*/
7public:
8 int state; /*what is it doing?*/
9 int index; /*index to animation frame*/
10 Picture *cels; /*pointer to array of animation frames*/
11 int x, y; /*location*/
12 int target_x; /*target x position*/
13 int target_y; /*target y position*/
14 int target_c; /*target computer*/
15 int cargo; /*which OS carried*/
16 int x_offset; /*accounts for width differences*/
17 int y_offset; /*'bounce' factor for OS carried*/
18 int sx, sy; /*used for drawing extra OS during switch*/
19
20 static const int SLOW = 0;/* speeds of moving bills */
21 static const int FAST = 1;
22
23 static const int OFF = 0;/* Bill's states */
24 static const int IN = 1;
25 static const int AT = 2;
26 static const int OUT = 3;
27 static const int DYING = 4;
28 static const int STRAY = 5;
29
30 static const int GRAVITY = 3;/*speed at which os drops*/
31
32 static const int XOFFSET = 20;/*offset from right of computer*/
33 static const int YOFFSET = 3;/*offset from top of computer*/
34
35 void get_border();
36 void enter();
37 int move(int mode);
38 void draw();
39 void draw_std();
40 void draw_at();
41 void draw_stray();
42 void update();
43 void update_in();
44 void update_at();
45 void update_out();
46 void update_dying();
47 int clicked(int locx, int locy);
48 int clickedstray(int locx, int locy);
49 int step_size(unsigned int lev);
50
51};
52
53#endif
diff --git a/noncore/games/kbill/Network.cc b/noncore/games/kbill/Network.cc
new file mode 100644
index 0000000..d163b16
--- a/dev/null
+++ b/noncore/games/kbill/Network.cc
@@ -0,0 +1,49 @@
1#include "objects.h"
2
3/*sets up network for each level*/
4void Network::setup() {
5 int i;
6 units = on (game.level);
7 for (i=0; i<units; i++)
8 if (!net.computers[i].setup(i)) {
9 units = i-1;
10 break;
11 }
12 base = units;
13 off = win = 0;
14 ncables = game.MIN(game.level, units/2);
15 for (i=0; i<ncables; i++) cables[i].setup();
16}
17
18/*redraws the computers at their location with the proper image*/
19void Network::draw () {
20 int i;
21 for (i=0; i<ncables; i++) cables[i].draw();
22 for (i=0; i<units; i++) computers[i].draw();
23}
24
25void Network::update () {
26 for (int i=0; i<ncables; i++) cables[i].update();
27}
28
29void Network::toasters () {
30 for (int i=0; i<units; i++) {
31 computers[i].type = computers[i].TOASTER;
32 computers[i].os = OS.OFF;
33 }
34 ncables=0;
35}
36
37int Network::on(int lev) {
38 return game.MIN(8+lev, MAX_COMPUTERS);
39}
40
41void Network::load_pix () {
42 int i;
43 char *name[] = {"toaster", "maccpu", "nextcpu", "sgicpu", "suncpu",
44 "os2cpu", "bsdcpu"};
45 for (i=0; i <= NUM_SYS; i++)
46 pictures[i].load(name[i]);
47 width = pictures[0].width;
48 height = pictures[0].height;
49}
diff --git a/noncore/games/kbill/Network.h b/noncore/games/kbill/Network.h
new file mode 100644
index 0000000..03ff148
--- a/dev/null
+++ b/noncore/games/kbill/Network.h
@@ -0,0 +1,27 @@
1#ifndef NETWORK_H
2#define NETWORK_H
3
4#include "Computer.h"
5#include "Cable.h"
6
7 class Network {/*structure for global network of computers*/
8public:
9 static const int MAX_COMPUTERS = 20;/* max computers on screen */
10 static const int NUM_SYS = 6; /* number of computer types */
11 Picture pictures[NUM_SYS+1]; /* array of cpu pictures */
12 int width, height; /* size of cpu picture */
13 int units; /* number of cpus in network */
14 int win, base, off; /* number in each state */
15 Computer computers[MAX_COMPUTERS];/* array of cpu info */
16 Cable cables[MAX_COMPUTERS];
17 int ncables;
18 void setup();
19 void load_pix();
20 void draw();
21 void update();
22 void toasters();
23 int on(int lev);
24
25};
26
27#endif
diff --git a/noncore/games/kbill/Picture.cc b/noncore/games/kbill/Picture.cc
new file mode 100644
index 0000000..79e19ba
--- a/dev/null
+++ b/noncore/games/kbill/Picture.cc
@@ -0,0 +1,72 @@
1/***************************************************************************
2 Picture.cc - description
3 -------------------
4 begin : Thu Dec 30 1999
5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
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 *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#include "Picture.h"
18#include "objects.h"
19
20#include <iostream.h>
21
22#include <qstring.h>
23#include <qpe/resource.h>
24#ifdef KDEVER
25#include <kapp.h>
26#include <kstandarddirs.h>
27#include <kdebug.h>
28#endif
29void Picture::load(const char *name, int index) {
30 //QString dir = KApplication::kde_datadir(), file;
31 // QString dir = locate("data",""),file;
32 // dir += "/kbill/";
33 // if (index>=0)
34 // file.sprintf ("%spixmaps/%s_%d.xpm", (const char *)dir, name, index);
35 // else
36 // file.sprintf("%spixmaps/%s.xpm", (const char *)dir, name);
37#ifdef KDEVER
38 KStandardDirs dirs;
39 QString file;
40
41 if (index>=0) {
42 //kdDebug() << "Here";
43 QString sindex;
44 sindex.setNum(index);
45 // kdDebug() << "kbill/pixmaps/" + QString::fromLocal8Bit(name) + "_" + sindex + ".xpm";
46 file = dirs.findResource("data","kbill/pixmaps/" + QString::fromLocal8Bit(name) + "_" + sindex + ".xpm");
47 } else {
48 file = dirs.findResource("data","kbill/pixmaps/" + QString::fromLocal8Bit(name) + ".xpm");
49 }
50 kdDebug() << file << endl;
51 pix = new QPixmap();
52 if (pix->load(file) == FALSE)
53 cerr << "cannot open " << file << endl;
54 width = pix->width();
55 height = pix->height();
56#endif
57QString sindex;
58pix = new QPixmap();
59sindex.setNum(index);
60if (index>=0)
61pix->load(Resource::findPixmap("kbill/pixmaps/" + QString::fromLocal8Bit(name) +"_"+ sindex));
62else
63pix->load(Resource::findPixmap("kbill/pixmaps/" + QString::fromLocal8Bit(name)));
64
65 width = pix->width();
66 height = pix->height();
67
68}
69
70QPixmap* Picture::getPixmap() {
71 return pix;
72}
diff --git a/noncore/games/kbill/Picture.h b/noncore/games/kbill/Picture.h
new file mode 100644
index 0000000..c423251
--- a/dev/null
+++ b/noncore/games/kbill/Picture.h
@@ -0,0 +1,32 @@
1/***************************************************************************
2 Picture.h - description
3 -------------------
4 begin : Thu Dec 30 1999
5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
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 *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef PICTURE_H
18#define PICTURE_H
19
20#include <qpixmap.h>
21
22class Picture {
23 public:int width, height;
24 void load(const char *name, int index=-1);
25 QPixmap* getPixmap();
26private:
27 QPixmap *pix;
28
29 friend class UI;
30};
31
32#endif
diff --git a/noncore/games/kbill/Scorelist.cc b/noncore/games/kbill/Scorelist.cc
new file mode 100644
index 0000000..8825373
--- a/dev/null
+++ b/noncore/games/kbill/Scorelist.cc
@@ -0,0 +1,75 @@
1#include <qstring.h>
2#ifdef KDEVER
3#include <kapplication.h>
4#include <kstandarddirs.h>
5#endif
6#include "objects.h"
7
8FILE *Scorelist::open_file(char *mode) {
9 // QString file;
10 // file.sprintf("%s/kbill/scores", (const char *)locate("data",""));
11 // //kdDebug() << locate("data","") << endl;
12 // return fopen (file, mode);
13}
14
15void Scorelist::read() {
16 // FILE *scorefile = open_file("r");
17 // int i;
18 // if (scorefile) {
19 // for (i=0; i<10; i++) {
20 // fgets (name[i], 21, scorefile);
21 // fscanf (scorefile, "%d%d\n", &(level[i]), &(score[i]));
22 // }
23 // fclose(scorefile);
24 // }
25 // else
26 // for (i=0; i<10; i++) {
27 // strcpy(name[i], "me");
28 // level[i] = score[i] = 0;
29 // }
30}
31
32void Scorelist::write() {
33 // int i, j;
34 // FILE *scorefile = open_file("w");
35 // if (!scorefile) return;
36 // for (i=0; i<10; i++) {
37 // fputs(name[i], scorefile);
38 // for (j=strlen(name[i]); j<25; j++)
39 // fputc(' ', scorefile);
40 // fprintf (scorefile, " %d %d\n", level[i], score[i]);
41 // }
42 // fclose(scorefile);
43}
44
45/* Add new high score to list */
46void Scorelist::recalc (char *str) {
47 // int i;
48 // if (score[9] >= game.score) return;
49 // for (i=9; i>0; i--) {
50 // if (score[i-1] < game.score) {
51 // strcpy (name[i], name[i-1]);
52 // level[i] = level[i-1];
53 // score[i] = score[i-1];
54 // }
55 // else break;
56 // }
57 // strcpy (name[i], str);
58 // level[i] = game.level;
59 // score[i] = game.score;
60}
61
62void Scorelist::update() {
63 // char str[500], temp[40];
64 // int i, j;
65 // strcpy (str,"High Scores:\n\n");
66 // strcat (str, "Name Level Score\n");
67 // for (i=0; i<10; i++) {
68 // strcat (str, name[i]);
69 // for (j=strlen(name[i]); j<21; j++) strcat (str, " ");
70 // sprintf (temp, "%5d %7d\n", level[i], score[i]);
71 // strcat (str, temp);
72 // }
73 // ui.update_hsbox(str);
74}
75
diff --git a/noncore/games/kbill/Scorelist.h b/noncore/games/kbill/Scorelist.h
new file mode 100644
index 0000000..0c8b0dd
--- a/dev/null
+++ b/noncore/games/kbill/Scorelist.h
@@ -0,0 +1,16 @@
1#ifndef SCORELIST_H
2#define SCORELIST_H
3
4class Scorelist {
5public:
6 char name[10][21];
7 unsigned level[10];
8 unsigned score[10];
9 FILE *open_file(char *mode);
10 void read();
11 void write();
12 void recalc(char *str);
13 void update();
14};
15
16#endif
diff --git a/noncore/games/kbill/Spark.cc b/noncore/games/kbill/Spark.cc
new file mode 100644
index 0000000..74c42fa
--- a/dev/null
+++ b/noncore/games/kbill/Spark.cc
@@ -0,0 +1,13 @@
1#include "objects.h"
2
3int Spark::delay(unsigned int lev) {
4 return game.MAX (20-lev, 0);
5}
6
7void Spark::load_pix() {
8 int i;
9 for (i=0; i<2; i++)
10 pictures[i].load("spark", i);
11 width = pictures[0].width;
12 height = pictures[0].height;
13}
diff --git a/noncore/games/kbill/Spark.h b/noncore/games/kbill/Spark.h
new file mode 100644
index 0000000..4fbe6c8
--- a/dev/null
+++ b/noncore/games/kbill/Spark.h
@@ -0,0 +1,16 @@
1#ifndef SPARK_H
2#define SPARK_H
3
4#include "Picture.h"
5
6class Spark {
7public:
8 Picture pictures[2];
9 int width, height;
10 void draw();
11 void load_pix();
12 static const int speed = 5;
13 int delay(unsigned int lev);
14};
15
16#endif
diff --git a/noncore/games/kbill/Strings.h b/noncore/games/kbill/Strings.h
new file mode 100644
index 0000000..45509d1
--- a/dev/null
+++ b/noncore/games/kbill/Strings.h
@@ -0,0 +1,58 @@
1#ifndef STRINGS_H
2#define STRINGS_H
3
4#define storystr \
5" The Story:\n\
6\n\
7Yet again, the fate of the world rests\n\
8in your hands! An evil computer hacker,\n\
9known only by his handle 'Bill', has\n\
10created the ultimate computer virus. A\n\
11virus so powerful that it has the power\n\
12to transmute an ordinary computer into\n\
13a toaster oven. (oooh!) 'Bill' has\n\
14cloned himself into a billion-jillion\n\
15micro-Bills. Their sole purpose is to\n\
16deliver the nefarious virus, which has\n\
17been cleverly diguised as a popular\n\
18operating system.\n\
19\n\
20As System Administrator/Exterminator,\n\
21your job is to keep Bill from succeeding\n\
22at his task."
23
24#define rulesstr \
25" The Rules:\n\
26\n\
27kBill has been painstakingly designed and\n\
28researched in order to make it as easy to use\n\
29for the whole family as it is for little Sally.\n\
30Years - nay - days of beta testing and \n\
31consulting with the cheapest of human interface\n\
32designers have resulted in a game that is easy\n\
33to use, yet nothing at all like a Macintosh.\n\
34\n\
35I. Whack the Bills (click)\n\
36II. Restart the computer (click)\n\
37III. Pick up stolen OSes & return(drag)\n\
38 them to their respective computers\n\
39IV. Drag the bucket to extinguish sparks\n\
40V. Scoring is based on total uptime,\n\
41 with bonuses for killing Bills.\n\
42\n\
43As for the rest, you can probably figure\n\
44it out. We did, so it can't be too hard."
45
46#define endgamestr \
47"Module kBill has caused a\n\
48segmentation fault at memory\n\
49address 097E:F1A0. Core dumped.\n\
50We apologize for the inconvenience."
51
52#define warpstr "Warp to level?"
53#define quitstr "Quit Game?"
54#define newgamestr "New Game?"
55#define pausestr "Game paused.\n Press OK to continue."
56#define enternamestr "You earned a high score.\nEnter your name:"
57
58#endif
diff --git a/noncore/games/kbill/UI.cpp b/noncore/games/kbill/UI.cpp
new file mode 100644
index 0000000..fac731a
--- a/dev/null
+++ b/noncore/games/kbill/UI.cpp
@@ -0,0 +1,175 @@
1/***************************************************************************
2 UI.cc - description
3 -------------------
4 begin : Thu Dec 30 1999
5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
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 *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#include "kbill.h"
18#include "objects.h"
19#include "Strings.h"
20#ifdef KDEVER
21#include <kapplication.h>
22#endif
23#include <qpixmap.h>
24#include <qmessagebox.h>
25#include <qnamespace.h>
26
27#include "inputbox.h"
28
29/**************************/
30/* Timer control routines */
31/**************************/
32
33UI::~UI() {
34 paint.end();
35 delete pix;
36}
37
38void UI::restart_timer() {
39 field->startTimer();
40}
41
42void UI::kill_timer() {
43 field->stopTimer();
44}
45
46/*******************/
47/* Window routines */
48/*******************/
49
50void UI::initialize(int *argc, char **argv) {
51 #ifdef KDEVER
52 app = new KApplication(*argc, argv, "kbill");
53 #endif
54 app = new QPEApplication(*argc, argv);
55}
56
57void UI::graph_init() {
58 pix = new QPixmap(Game::scrwidth, Game::scrheight);
59 paint.begin(pix, field);
60 paint.setPen(QPen(Qt::black, 3));
61}
62
63void UI::make_mainwin() {
64 main = new KBill();
65 app->showMainWidget(main,true);
66 main->showMaximized();
67 field = main->getField();
68}
69
70void UI::popup_dialog (int dialog) {
71 kill_timer();
72 switch (dialog) {
73 case Game::ENDGAME:
74 QMessageBox::message(("Endgame"), (endgamestr));
75 break;
76 case Game::HIGHSCORE:
77 //QMessageBox::message(("HighScore"), highscorestr);
78 break;
79 case Game::ENTERNAME: {
80 InputBox b(main, 0, ("Enter Name"), (enternamestr));
81 bool state = b.exec() == 2;
82 char str[20], *nl;
83 strcpy(str, b.getText());
84 if (!str[0] || state)
85 strcpy(str, "Anonymous");
86 else if ((nl = strchr(str, '\n')))
87 *nl = '\0';
88 if (strlen(str) > 20)
89 str[20] = 0; /* truncate string if too long */
90 // scores.recalc(str);
91 }
92 break;
93 case Game::SCORE:
94 QMessageBox::message(("Score"), scorestr);
95 break;
96 }
97 restart_timer();
98}
99
100/*********************/
101/* Graphics routines */
102/*********************/
103
104void UI::set_cursor(int cursor) {
105 QCursor *cur;
106 switch (cursor) {
107 case Game::BUCKETC:
108 cur = bucket.cursor.cursor;
109 break;
110 case Game::DOWNC:
111 cur = downcursor.cursor;
112 break;
113 case Game::DEFAULTC:
114 cur = defaultcursor.cursor;
115 break;
116 default:
117 cur = OS.cursor[cursor].cursor;
118 }
119 field->setCursor(*cur);
120}
121
122void UI::load_cursors() {
123 defaultcursor.load("hand_up", MCursor::SEP_MASK);
124 field->setCursor(*defaultcursor.cursor);
125 downcursor.load("hand_down", MCursor::SEP_MASK);
126}
127
128void UI::clear() {
129 paint.eraseRect(0, 0, field->width(), field->height());
130}
131
132void UI::refresh() {
133 paint.flush();
134 field->setPixmap(pix);
135 field->repaint(FALSE);
136}
137
138void UI::draw (Picture pict, int x, int y) {
139 paint.drawPixmap(x, y, *pict.pix);
140}
141
142void UI::draw_centered (Picture pict) {
143 draw(pict, (field->width() - pict.width) / 2, (field->height() - pict.height) / 2);
144}
145
146void UI::draw_line(int x1, int y1, int x2, int y2) {
147 paint.drawLine(x1, y1, x2, y2);
148
149}
150
151void UI::draw_str(char *str, int x, int y) {
152 paint.drawText(x, y, str);
153}
154
155
156/******************/
157/* Other routines */
158/******************/
159
160void UI::set_pausebutton (int action) {
161 main->file->setItemEnabled(main->pauseid, action);
162}
163
164
165int UI::MainLoop() {
166 return app->exec();
167}
168
169void UI::update_hsbox(char *str) {
170 highscorestr = str;
171}
172
173void UI::update_scorebox(int level, int score) {
174 scorestr.sprintf ("%s %d:\n%s: %d", ("After Level"), level, ("Your score"), score);
175}
diff --git a/noncore/games/kbill/UI.h b/noncore/games/kbill/UI.h
new file mode 100644
index 0000000..8eaf6fd
--- a/dev/null
+++ b/noncore/games/kbill/UI.h
@@ -0,0 +1,73 @@
1/***************************************************************************
2 UI.h - description
3 -------------------
4 begin : Thu Dec 30 1999
5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
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 *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef UI_H
18#define UI_H
19
20#include <qpe/qpeapplication.h>
21#include <qobject.h>
22#include <qpixmap.h>
23#include <qpainter.h>
24#include <qstring.h>
25
26#include "Picture.h"
27#include "MCursor.h"
28
29#include "field.h"
30#include "kbill.h"
31
32class UI {
33public:
34 ~UI();
35 void restart_timer();
36 void kill_timer();
37
38 void initialize(int *argc, char **argv);
39 void make_mainwin();
40 void make_windows() {};
41 void popup_dialog (int dialog);
42
43 void set_cursor (int cursor);
44 void load_cursors();
45 void graph_init();
46 void clear();
47 void refresh();
48 void draw (Picture picture, int x, int y);
49 void draw_centered (Picture picture);
50 void draw_line (int x1, int y1, int x2, int y2);
51 void draw_str (char *str, int x, int y);
52
53 void set_pausebutton (int action);
54 int MainLoop();
55
56 void update_scorebox(int level, int score);
57 void update_hsbox(char *str);
58private:
59 MCursor defaultcursor, downcursor;
60
61 QPEApplication *app;
62 QTimer* timer;
63
64 Field* field;
65 KBill* main;
66
67 QPixmap *pix;
68 QPainter paint;
69
70 QString scorestr, highscorestr;
71};
72
73#endif
diff --git a/noncore/games/kbill/field.cpp b/noncore/games/kbill/field.cpp
new file mode 100644
index 0000000..a1b3560
--- a/dev/null
+++ b/noncore/games/kbill/field.cpp
@@ -0,0 +1,84 @@
1/***************************************************************************
2 field.cpp - description
3 -------------------
4 begin : Thu Dec 30 1999
5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
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 *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include <qpainter.h>
19
20#include "objects.h"
21
22#include "field.h"
23
24Field::Field(QWidget *parent, const char *name ) : QWidget(parent,name) {
25 setFixedSize(game.scrwidth, game.scrheight);
26 setBackgroundColor(white);
27 timer = new QTimer(this);
28
29 playing = false;
30
31 connect(timer, SIGNAL(timeout()), SLOT(Timer()));
32}
33
34Field::~Field(){
35 delete timer;
36}
37
38void Field::setPixmap(QPixmap *pix) {
39 this->pix = pix;
40}
41
42// --------------------------------------------------------
43
44void Field::mousePressEvent(QMouseEvent *e){
45 game.button_press(e->x(), e->y());
46}
47
48void Field::mouseReleaseEvent(QMouseEvent *e){
49 game.button_release(e->x(), e->y());
50}
51
52void Field::enterEvent(QEvent *) {
53 if (playing && !timer->isActive()) {
54 playing = true;
55 timer->start(250, FALSE);
56 }
57}
58
59void Field::leaveEvent(QEvent *) {
60 if (timer->isActive() && playing) {
61 playing = true;
62 timer->stop();
63 }
64}
65
66void Field::stopTimer() {
67 playing = false;
68 if (timer->isActive())
69 timer->stop();
70}
71
72void Field::startTimer() {
73 playing = true;
74 if (!timer->isActive())
75 timer->start(250, FALSE);
76}
77
78void Field::Timer(){
79 game.update();
80}
81
82void Field::paintEvent(QPaintEvent *) {
83 bitBlt(this, 0, 0, pix);
84 } \ No newline at end of file
diff --git a/noncore/games/kbill/field.h b/noncore/games/kbill/field.h
new file mode 100644
index 0000000..9f355ed
--- a/dev/null
+++ b/noncore/games/kbill/field.h
@@ -0,0 +1,48 @@
1/***************************************************************************
2 field.h - description
3 -------------------
4 begin : Thu Dec 30 1999
5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
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 *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef FIELD_H
19#define FIELD_H
20
21#include <qwidget.h>
22#include <qpixmap.h>
23#include <qpainter.h>
24#include <qtimer.h>
25
26class Field : public QWidget {
27 Q_OBJECT
28public:
29 Field(QWidget *parent=0, const char *name=0);
30 ~Field();
31 void stopTimer();
32 void startTimer();
33 void setPixmap(QPixmap *pix);
34protected:
35 void mouseReleaseEvent(QMouseEvent *e);
36 void mousePressEvent(QMouseEvent *e);
37 void enterEvent(QEvent *);
38 void leaveEvent(QEvent *);
39 void paintEvent(QPaintEvent *);
40public slots:
41 void Timer();
42private:
43 QTimer* timer;
44 QPixmap *pix;
45 bool playing;
46};
47
48#endif
diff --git a/noncore/games/kbill/inputbox.cpp b/noncore/games/kbill/inputbox.cpp
new file mode 100644
index 0000000..b191ea8
--- a/dev/null
+++ b/noncore/games/kbill/inputbox.cpp
@@ -0,0 +1,51 @@
1/***************************************************************************
2 inputbox.cpp - description
3 -------------------
4 begin : Sat Jan 1 2000
5 copyright : (C) 2000 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
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 *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "inputbox.h"
19#include <qdialog.h>
20InputBox::InputBox(QWidget *parent, const char *name, const char *caption, const char *text) : QDialog(parent, name, TRUE) {
21 // setCaption(caption);
22//
23 // question = new QLabel(this);
24 // question->setText(text);
25 // question->setGeometry(10, 10, 240, 50);
26//
27 // input = new QLineEdit(this);
28// input->setGeometry(10, 60, 240, 30);
29 // input->setFocus();
30 // input->setMaxLength(19);
31//
32// ok = new QPushButton( "Ok", this );
33// ok->setGeometry(10, 100, 100,30 );
34 // ok->setDefault(TRUE);
35// connect( ok, SIGNAL(clicked()), SLOT(accept()) );
36//
37// cancel = new QPushButton( "Cancel", this );
38// cancel->setGeometry(150, 100, 100,30 );
39// connect( cancel, SIGNAL(clicked()), SLOT(reject()) );
40}
41
42InputBox::~InputBox(){
43 delete ok;
44 delete cancel;
45 delete question;
46 delete input;
47}
48
49QString InputBox::getText() const{
50 return input->text();
51}
diff --git a/noncore/games/kbill/inputbox.h b/noncore/games/kbill/inputbox.h
new file mode 100644
index 0000000..0a64048
--- a/dev/null
+++ b/noncore/games/kbill/inputbox.h
@@ -0,0 +1,39 @@
1/***************************************************************************
2 inputbox.h - description
3 -------------------
4 begin : Sat Jan 1 2000
5 copyright : (C) 2000 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
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 *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef INPUTBOX_H
19#define INPUTBOX_H
20
21#include <qdialog.h>
22#include <qpushbutton.h>
23#include <qlabel.h>
24
25#include <qstring.h>
26#include <qlineedit.h>
27class InputBox : public QDialog {
28 Q_OBJECT
29public:
30 InputBox(QWidget *parent=0, const char *name=0, const char *caption = 0, const char *text=0);
31 ~InputBox();
32 QString getText() const;
33private:
34 QPushButton *ok, *cancel;
35 QLabel *question;
36 QLineEdit *input;
37};
38
39#endif
diff --git a/noncore/games/kbill/kbill.cpp b/noncore/games/kbill/kbill.cpp
new file mode 100644
index 0000000..568df95
--- a/dev/null
+++ b/noncore/games/kbill/kbill.cpp
@@ -0,0 +1,118 @@
1/***************************************************************************
2 kbill.cpp - description
3 -------------------
4 begin : Thu Dec 30 16:55:55 CET 1999
5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
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 *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include <qmessagebox.h>
19#include <qmenubar.h>
20#include "kbill.h"
21#include "inputbox.h"
22
23#include "objects.h"
24#include "Strings.h"
25
26KBill::KBill() : QMainWindow() {
27 setCaption("kBill");
28 file = new QPopupMenu();
29 file->insertItem(("New game"), this, SLOT(NewGame()));
30 pauseid = file->insertItem(("Pause game"), this, SLOT(Pause()));
31 //these are dissabled until I fix them
32 //file->insertItem(("Warp to level..."), this, SLOT(WarpTo()));
33 //file->insertItem(("View high scores"), this, SLOT(ViewHighScores()));
34 file->insertItem(("Quit game"), this, SLOT(Quit()));
35
36 help = new QPopupMenu();
37 help->insertItem(("Story of kBill"), this, SLOT(Story()));
38 help->insertItem(("Rules"), this, SLOT(Rules()));
39
40
41 menu = new QMenuBar(this);
42 menu->insertItem(("&File"), file);
43 menu->insertSeparator();
44 menu->insertItem(("&Help"), help);
45
46 field = new Field(this);
47 //setView(field);
48 //setMainWidget(field);
49 //setMenu(menu);
50}
51
52KBill::~KBill() {
53}
54
55Field* KBill::getField() {
56 return field;
57}
58
59// -----------------------------------------------------------------------
60
61void KBill::Quit() {
62 field->stopTimer();
63 qApp->quit();
64
65}
66
67void KBill::About(){
68 // field->stopTimer();
69 // AboutBox about(this);
70 // about.exec();
71 // field->startTimer();
72}
73
74void KBill::NewGame() {
75 field->stopTimer();
76 // if (KMsgBox::yesNo(this, i18n("New Game"), i18n(newgamestr), KMsgBox::QUESTION) == 1)
77 game.start(1);
78 // else
79 field->startTimer();
80}
81
82void KBill::Pause() {
83 field->stopTimer();
84 QMessageBox::message(("Pause Game"), (pausestr), 0);
85 field->startTimer();
86}
87
88void KBill::WarpTo() {
89 /* field->stopTimer();
90 InputBox b(this, 0, "Warp To Level", warpstr);
91 bool status = b.exec() == 1;
92 field->startTimer();
93 if (status) {
94 bool ok;
95 int level = b.getText().toUInt(&ok);
96 if (ok) {
97 field->startTimer();
98 game.warp_to_level(level);
99 return;
100 }
101 }*/
102}
103
104void KBill::ViewHighScores() {
105 //ui.popup_dialog(Game::HIGHSCORE);
106}
107
108void KBill::Story() {
109 field->stopTimer();
110 QMessageBox::message( ("Story"), (storystr), 0);
111 field->startTimer();
112}
113
114void KBill::Rules() {
115 field->stopTimer();
116 QMessageBox::message(("Rules"), (rulesstr), 0);
117 field->startTimer();
118}
diff --git a/noncore/games/kbill/kbill.h b/noncore/games/kbill/kbill.h
new file mode 100644
index 0000000..fbc0c6c
--- a/dev/null
+++ b/noncore/games/kbill/kbill.h
@@ -0,0 +1,54 @@
1/***************************************************************************
2 kbill.h - description
3 -------------------
4 begin : Thu Dec 30 16:55:55 CET 1999
5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
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 *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef KBILL_H
19#define KBILL_H
20
21
22
23#include <qmainwindow.h>
24#include <qwidget.h>
25#include <qpopupmenu.h>
26
27#include "field.h"
28
29class KBill : public QMainWindow
30{
31 Q_OBJECT
32 public:
33 KBill();
34 ~KBill();
35 Field* getField();
36 private:
37 QMenuBar *menu;
38 QPopupMenu *file, *help;
39 Field *field;
40 int pauseid;
41 protected slots:
42 void Quit();
43 void About();
44 void NewGame();
45 void Pause();
46 void WarpTo();
47 void Story();
48 void Rules();
49 void ViewHighScores();
50
51 friend class UI;
52};
53
54#endif
diff --git a/noncore/games/kbill/kbill.pro b/noncore/games/kbill/kbill.pro
new file mode 100644
index 0000000..2091dd0
--- a/dev/null
+++ b/noncore/games/kbill/kbill.pro
@@ -0,0 +1,13 @@
1TEMPLATE = app
2CONFIG = qt warn_on release
3DESTDIR = $(OPIEDIR)/bin
4HEADERS = kbill.h field.h Bucket.h Cable.h Computer.h Game.h Horde.h \
5Library.h MCursor.h Monster.h Network.h Picture.h Spark.h Strings.h \
6UI.h objects.h inputbox.h
7SOURCES = field.cpp Bucket.cc Cable.cc Computer.cc Game.cc Horde.cc \
8Library.cc MCursor.cc Monster.cc Network.cc Picture.cc \
9Spark.cc UI.cpp inputbox.cpp kbill.cpp
10TARGET = kbill
11INCLUDEPATH += $(OPIEDIR)/include
12DEPENDPATH += $(OPIEDIR)/include
13LIBS += -lqpe
diff --git a/noncore/games/kbill/kbill.xpm b/noncore/games/kbill/kbill.xpm
new file mode 100644
index 0000000..1a17dd8
--- a/dev/null
+++ b/noncore/games/kbill/kbill.xpm
@@ -0,0 +1,69 @@
1/* XPM */
2static char* icon_xpm[] = {
3"50 50 16 1",
4"_ c #ffffff",
5"` c #ffff94",
6"a c #f7ffff",
7"b c #f7f7de",
8"c c #debd5a",
9"d c #deb552",
10"e c #adcee7",
11"f c #8ca573",
12"g c #6bb5ef",
13"h c #634263",
14"i c #523152",
15"j c #42b5ef",
16"k c #313963",
17"l c #0073b5",
18"m c #004a8c",
19"n c #000000",
20"__________________________________________________",
21"__________________________gegg____________________",
22"____________gjlllllggellllllllllljg_______________",
23"_____jlllllllllllgaeaaaaagggjjjljllll_____________",
24"____ljjljjgaejjjgaeaaaaaealjgjjgljjjlll___________",
25"___lljjjjgaejjjgaea_beeeehgljjjljjjjjgeel_________",
26"___lljjljaejjjgaeaabbb`bcdiigejjjjjjjeaaall_______",
27"__glejllagljjgaeaabbb`bcdddiilkjjjjjjaaaaella_____",
28"__glgjgagllllaea__bb`bcddddddlcijijjgaa_agjl______",
29"__lljgagllljagaa_bb`bcdddddddlfdidijeaaeeljl______",
30"__ljgaellllaeaa_eb`bcddddddddlfiddij_eaagjjjl_____",
31"__lgaejjljagaa_`b`bcdddddddddlfddddf_aaajjjjjl____",
32"__lggjjjgagaaaeb`bcddddddddddlfddddbeaaejjjjjl____",
33"__llljjgaeaaaeb`bcdddddddddddlfdddd_faajjjjjjl____",
34"__ljllgaaaaage`bcdddddddnnnndlfddd`__aajjjjjjl____",
35"__ljjlaaaaageebcnnnndddn____nlfdddb`bagjjjjjjl____",
36"__ljgaeaaaeagecn____ndn_____nlfddc_`aejjjjjjjl____",
37"__lgaeeaaeaeelkn____ndn______kknn`e_ejjjjjjjjl____",
38"__laeaaaeaeallln_____nn______kgbiafbgljjjjjjjl____",
39"__leeaagaeajjkin_____nn______kg_hagajmljjjjjjl____",
40"__eeaaeeeajjjiin_____n_n_____kmiee_eijmljjjjjl____",
41"__eaaeaeejjjji_nn___n_bn____ngli_h__iljmljjjjl____",
42"__gaeeealjjjjib_bnnn_b_bnnnn_klf___iimjjmljjjl____",
43"__jgeeajlljjjiiii``ibib_b_b_ielab_bimmmjjmljjl____",
44"__jegaljjljjjjji```i_bib_b_i`ela___immmmjjmljl____",
45"__leellljlljjjjji```i_b_b_i``eleeeiimmmmmjjmjj____",
46"__galllljjlljjjjk````i_b_ii`_elb_fijmmmmmmljeg____",
47"__llllllljlljjjjlk``i`iii``_bagb_ijjjmmmmmmlaj____",
48"__llllllljjljjjjlli`i`i``h_b__g_ejjjjjjmmmmggl____",
49"__llllllljjlljjjjli`i`i`h_b__bebgljjjjjjmmmamg____",
50"__ljlllllljjljjjjji``ii`bb__b_aammljjjjjjmlele____",
51"__lljlllllljlljjjji``ihbb__b__gfmmmljjjjjjelgg____",
52"__ljjlllllljjljjjji```bf__b__bjkmmmmljjjjgameg____",
53"__ljjjlllllljlljjji``_f__b__bbmkmmmmmljjjeeeaa____",
54"__lljjllllllljlljji`_b__b___b`mimmmmmmljjaeaag____",
55"__lljjjlllllljlljjgbeaaee__fiimmlmmmmmmmeeeaam____",
56"__lljjjjlllllljljgaea_b___b```mkjmmmmmmmagaaam____",
57"__lljjjjlllllljljbeaab__a`````mkijmmmmmmelaaemj___",
58"__lljjjjjlllllljbeaab__bhiii`imkijjlmmmelggejle___",
59"__gljjjjjlllllgaeaaebbb`ijjiiikiijjjlmmamaejgl____",
60"__eljjjjjjllllaaaa__bfiilliiiikmjjllmmggmeejlj____",
61"__aeejgjjjllleeaa__bfiiillkkmmlmmlllllajeeejme____",
62"__ajljjjllllegaaaaagliilllmlllljlmljjgejaelmljjjj_",
63"___ajmlllllaeaaaaaejjjjjlmlllllljlmllelmgljjljjjje",
64"_jlljlmmmmeeaaaaeellllllmmljjlllllllmglljjjjjljjge",
65"jjjjjjllllmllmmmmmmmmmmllllmmmmmmlllljjjjjjjjljge_",
66"__gljljjjjjjjjjjjjllllljjllllllljjljjjjjjjjjjljg__",
67"___jlljjjjjjjjjjjjjjjjjjjlljjjjjjjljjjjjjjjg______",
68"___________gjjjggjggjjjjjjlljjjjjjj_______________",
69"_________________________ggljjg___________________"};
diff --git a/noncore/games/kbill/mini-kbill.xpm b/noncore/games/kbill/mini-kbill.xpm
new file mode 100644
index 0000000..8554383
--- a/dev/null
+++ b/noncore/games/kbill/mini-kbill.xpm
@@ -0,0 +1,248 @@
1/* XPM */
2static char*xbill[]={
3"16 16 229 2",
4".G c #648b97",
5"bB c #83cbf2",
6"## c #eaebcd",
7"be c #4ea5d7",
8".h c #89c1e4",
9"aV c #5c5c6b",
10"#c c #63b5e1",
11"#y c #fcfcfc",
12"bx c #bde5f9",
13"bH c #c0e5f9",
14"b# c #0965a4",
15"#m c #5f7987",
16"ai c #327ab2",
17"aP c #0376b7",
18"bG c #addcf4",
19"#Y c #c9bf89",
20"bE c #49b5ed",
21".J c #f0fafc",
22"#p c #4ab5ed",
23"#K c #a69c99",
24"bh c #2897d4",
25"a8 c #79a5bb",
26"#O c #f0f3ec",
27"a6 c #b9daee",
28"bw c #add6ed",
29"aS c #eaf1e6",
30"#H c #39ace8",
31".p c #e9f4f5",
32"bm c #066bac",
33"#2 c #afbcc4",
34".E c #e6cb76",
35"aQ c #3d99cf",
36"#. c #e0ba58",
37"#N c #709bb3",
38"#D c #40b3ed",
39"#8 c #087bbc",
40"aA c #1588c8",
41".9 c #709178",
42".K c #50a4d5",
43"aB c #5eb1e1",
44".A c #399cd3",
45"#3 c #2e71a8",
46".k c #5ab0de",
47".Y c #3eaee9",
48".w c #e8f3f8",
49"by c #a4d9f7",
50".Q c #e8f5f3",
51"bz c #83cdf4",
52"aK c #a4c6de",
53"bA c #88cdf4",
54"a4 c #2c9cd9",
55"aj c #81b7dd",
56"#L c #cbc7bf",
57".0 c #a5cee6",
58"#n c #b0a171",
59"az c #178ac9",
60".# c #fcfefe",
61"bv c #9ed0f2",
62"aZ c #87bfe5",
63"#g c #c2def0",
64".g c #8dc2e3",
65".q c #d7e8ed",
66".i c #edf6fc",
67"aC c #e3eee9",
68"#9 c #0578b9",
69".3 c #d9eefa",
70".z c #65b2df",
71"a5 c #298cc4",
72"#F c #aed2ed",
73".S c #e6cb77",
74"al c #0073b5",
75"aa c #3483b9",
76"a9 c #2d6497",
77"ah c #349eda",
78"bc c #6db1dc",
79"bF c #7dcaf1",
80"#d c #a8d0e7",
81"ae c #e2eff2",
82"a7 c #f4fcfe",
83"bt c #41b3ee",
84"aw c #bdddf3",
85"#u c #465270",
86"#e c #a5d5f1",
87".5 c #beab69",
88"aI c #2971a9",
89"av c #87c0e3",
90"#S c #62b4e0",
91"#J c #ada779",
92"an c #2194d2",
93".n c #3ca5df",
94"au c #0b65a6",
95"bn c #107aba",
96"aT c #b2afae",
97".o c #a2d0ed",
98"#B c #8cadca",
99".2 c #b6e0f7",
100"#h c #547d90",
101"aW c #3f73a4",
102"b. c #105a95",
103"#b c #42b5ef",
104"aR c #d1e9f1",
105"aG c #185a95",
106".y c #3d9fd8",
107"a1 c #fdfeff",
108"ax c #a3cde4",
109"#o c #c6e0db",
110"aN c #30a3df",
111"bg c #81c7ee",
112"af c #5da0ca",
113"aY c #3f7fb3",
114"#E c #c5e6f9",
115"aX c #0f6faf",
116".X c #cce9f7",
117"aO c #38abe7",
118"#G c #57addc",
119"aD c #ecf3f4",
120".x c #cce5f6",
121"#t c #70c6f1",
122".R c #f2f4ca",
123"a. c #2699d7",
124"bd c #64acd9",
125".O c #3ea0d6",
126"#x c #a6a6a4",
127".7 c #bb9b4f",
128"#q c #cce3f0",
129"#v c #cacaca",
130".s c #47b2ec",
131"#j c #a59b82",
132".L c #f0f7fb",
133".c c #afd7ed",
134"bu c #2da0dc",
135"#5 c #1471b0",
136"ag c #3bade8",
137"as c #aac6cf",
138"#a c #94d4f5",
139"bC c #7fccf3",
140".e c #d1e7f7",
141"aH c #004a8c",
142".v c #aed2e9",
143"ap c #e6e19b",
144"#r c #d8eaf5",
145".u c #359fd9",
146".l c #2b9bd8",
147".H c #5097c0",
148"ac c #b4a585",
149".U c #79977c",
150"ba c #0f74b4",
151"#7 c #a4cde5",
152"#0 c #c8be9a",
153"aU c #667383",
154"bk c #73b1d8",
155".V c #c19a52",
156".a c #f5f9fc",
157".b c #edf5fb",
158"aM c #b9d9ee",
159"ao c #4594c8",
160".4 c #d6e5d5",
161"bD c #2691d0",
162"#Q c #1d7bb9",
163".D c #f8f7c9",
164".M c #a6cfe6",
165"#w c #b4b4b4",
166".d c #a7cfe6",
167"aF c #7a8d85",
168".W c #b0c5c7",
169"bI c #f5fbfd",
170"a2 c #f6fbfd",
171".1 c #2b98d5",
172".I c #66bded",
173".N c #83c5ef",
174"#i c #cac9c8",
175"am c #1386c5",
176"#l c #fafafa",
177"#U c #3791c5",
178"br c #1b86c5",
179"#C c #1d86c5",
180"bp c #066cad",
181"ar c #fcfcf5",
182"bi c #1379b9",
183"aq c #d8daca",
184".Z c #92cae8",
185"#W c #1b8ecd",
186"#A c #abaabd",
187".P c #84c2e6",
188".8 c #9f8a5a",
189"ab c #bdb07b",
190".j c #fbfdfe",
191".6 c #cca64b",
192"ay c #2fa2de",
193"#z c #6184a8",
194".T c #deb552",
195"#k c #a9a6a0",
196".r c #5f9ccb",
197"#R c #1f88c6",
198"a3 c #55adde",
199"#X c #8aa592",
200"#1 c #a5cddb",
201"#4 c #014c8e",
202"ak c #2a9dda",
203".t c #2d9dda",
204"bb c #1a83c2",
205".f c #afd3e8",
206"ad c #efece6",
207"#Z c #c3b8b6",
208"aL c #feffff",
209"Qt c #ffffff",
210".B c #a2d4f1",
211"aJ c #c0dff1",
212"#6 c #97d0f0",
213"bo c #0871b2",
214"#P c #566489",
215"bs c #35a4df",
216"#s c #bcdbf0",
217"#V c #1386c6",
218".F c #b79154",
219".m c #72b7e1",
220"at c #114c83",
221"#f c #e3f2f9",
222"bq c #0e79ba",
223"#M c #9b9794",
224"bf c #b1dff7",
225"#T c #b3d6ec",
226"a# c #39ace7",
227"#I c #6a85a6",
228".C c #f1f8f5",
229"bl c #4c95c7",
230"a0 c #62aedc",
231"bj c #4b9dcf",
232"aE c #f0f2cc",
233"Qt.#.a.b.c.d.e.f.g.h.c.iQtQtQtQt",
234".j.k.l.m.n.o.p.q.r.s.t.u.v.wQtQt",
235".x.y.z.A.B.C.D.E.F.G.H.I.J.K.LQt",
236".M.N.O.P.Q.R.S.T.T.U.V.W.X.Y.ZQt",
237".0.1.2.3.4.5.6.7.8.9#.###a#b#cQt",
238"#d#e#f#g#h#i#j#k#l#m#n#o#p#b#cQt",
239"#q#r#s#t#u#v#w#x#y#z#A#B#C#D#cQt",
240"#E#F#G#H#I#J#K#L#M#N#O#P#Q#R#SQt",
241"#T#U#V#W#b#X#Y#Z#0#1#2#3#4#5#6Qt",
242"#7#8#9a.a#aaabacadaeafagahaiajQt",
243".0akalamanaoapaqarasatauagavawQt",
244"axayazalaAaBaCaDaEaFaGaHaIaJaKaL",
245"aMaNaOaPaQaRaSaTaUaVaWaXaYaZa0a1",
246"a2a3a4a5a6a7a8a9b.b#babbbcbdbebf",
247"bgbhbibjbkblbmbnbobpbqbrbsbtbubv",
248".jbwbxbybzbAbBbCbDbEbFbGbxbHbIa1"};
diff --git a/noncore/games/kbill/objects.h b/noncore/games/kbill/objects.h
new file mode 100644
index 0000000..2184ce7
--- a/dev/null
+++ b/noncore/games/kbill/objects.h
@@ -0,0 +1,26 @@
1#ifndef OBJECTS_H
2#define OBJECTS_H
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <string.h>
7#include <unistd.h>
8#include <time.h>
9
10#include "Horde.h"
11#include "Network.h"
12#include "Library.h"
13#include "Bucket.h"
14#include "Spark.h"
15#include "Game.h"
16#include "UI.h"
17
18extern Horde bill;
19extern Network net;
20extern Library OS;
21extern Bucket bucket;
22extern Spark spark;
23extern Game game;
24extern UI ui;
25
26#endif