author | mark <mark> | 2002-04-14 17:08:03 (UTC) |
---|---|---|
committer | mark <mark> | 2002-04-14 17:08:03 (UTC) |
commit | bfeb067c8acfb5f1797fdc886ac71ca1b10ccf57 (patch) (unidiff) | |
tree | ad77e90c90f4bfb598bbe93aa4b3e14b689c96f4 /noncore/games/kbill/Computer.cc | |
parent | a0fe593db4e700989cc19e28b67a58f87823afeb (diff) | |
download | opie-bfeb067c8acfb5f1797fdc886ac71ca1b10ccf57.zip opie-bfeb067c8acfb5f1797fdc886ac71ca1b10ccf57.tar.gz opie-bfeb067c8acfb5f1797fdc886ac71ca1b10ccf57.tar.bz2 |
Import of kbill
Diffstat (limited to 'noncore/games/kbill/Computer.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/kbill/Computer.cc | 56 |
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 | |||
3 | int 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 | |||
26 | int 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 | |||
37 | int Computer::oncomputer (int locx, int locy) { | ||
38 | return (abs(locx-x) < net.width && abs(locy-y) < net.height); | ||
39 | } | ||
40 | |||
41 | int Computer::compatible (int system) { | ||
42 | return (type==system || (type>=PC && system>=OS.PC)); | ||
43 | } | ||
44 | |||
45 | int Computer::determineOS() { | ||
46 | if (type<PC) return type; | ||
47 | else return game.RAND (OS.PC, OS.NUM_OS); | ||
48 | } | ||
49 | |||
50 | void 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 | |||