summaryrefslogtreecommitdiff
path: root/noncore/games/kbill/Computer.cc
blob: 7bd4bd3cc05611be8a190ac15d62168dbeb9412b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "objects.h"

int Computer::setup(int i) {
	int j, counter=0, flag;
	do {
		if (++counter>4000) return 0;
		x = game.RAND(BORDER, game.scrwidth - BORDER - net.width);
		y = game.RAND(BORDER, game.scrheight - BORDER - net.height);
		flag=1;
		/*checks for conflicting computer placement*/
		for (j=0; j<i && flag; j++)
			if (game.INTERSECT(x, y,
				net.width-bill.list[0].XOFFSET+bill.width,
				net.height, net.computers[j].x,
				net.computers[j].y,
				net.width-bill.list[0].XOFFSET+bill.width,
				net.height))
					flag=0;
	} while (!flag);
	type = game.RAND(1, net.NUM_SYS);
	os = determineOS();
	busy=0;
	return 1;
}

int Computer::find_stray() {
	int i;
	for (i=0; i < bill.MAX_BILLS; i++) {
		if (bill.list[i].state != bill.list[i].STRAY) continue;
		if (game.INTERSECT(x, y, net.width, net.height, bill.list[i].x,
			bill.list[i].y, OS.width, OS.height))
				return i;
	}
	return -1;
}

int Computer::oncomputer (int locx, int locy) {
	return (abs(locx-x) < net.width && abs(locy-y) < net.height);
}

int Computer::compatible (int system) {
	return (type==system || (type>=PC && system>=OS.PC));
}

int Computer::determineOS() {
	if (type<PC) return type;
	else return game.RAND (OS.PC, OS.NUM_OS);
}

void Computer::draw() {
	ui.draw(net.pictures[type], x, y);
	if (os != OS.OFF)
		ui.draw(OS.os[os], x + OFFSET, y + OFFSET);
}