summaryrefslogtreecommitdiff
path: root/noncore/games/kbill/Computer.cc
Unidiff
Diffstat (limited to 'noncore/games/kbill/Computer.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/kbill/Computer.cc56
1 files changed, 56 insertions, 0 deletions
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