00001 #include "objects.h"
00002
00003 int Computer::setup(int i) {
00004 int j, counter=0, flag;
00005 do {
00006 if (++counter>4000) return 0;
00007 x = game.RAND(BORDER, game.scrwidth - BORDER - net.width);
00008 y = game.RAND(BORDER, game.scrheight - BORDER - net.height);
00009 flag=1;
00010
00011 for (j=0; j<i && flag; j++)
00012 if (game.INTERSECT(x, y,
00013 net.width-bill.list[0].XOFFSET+bill.width,
00014 net.height, net.computers[j].x,
00015 net.computers[j].y,
00016 net.width-bill.list[0].XOFFSET+bill.width,
00017 net.height))
00018 flag=0;
00019 } while (!flag);
00020 type = game.RAND(1, net.NUM_SYS);
00021 os = determineOS();
00022 busy=0;
00023 return 1;
00024 }
00025
00026 int Computer::find_stray() {
00027 int i;
00028 for (i=0; i < bill.MAX_BILLS; i++) {
00029 if (bill.list[i].state != bill.list[i].STRAY) continue;
00030 if (game.INTERSECT(x, y, net.width, net.height, bill.list[i].x,
00031 bill.list[i].y, OS.width, OS.height))
00032 return i;
00033 }
00034 return -1;
00035 }
00036
00037 int Computer::oncomputer (int locx, int locy) {
00038 return (abs(locx-x) < net.width && abs(locy-y) < net.height);
00039 }
00040
00041 int Computer::compatible (int system) {
00042 return (type==system || (type>=PC && system>=OS.PC));
00043 }
00044
00045 int Computer::determineOS() {
00046 if (type<PC) return type;
00047 else return game.RAND (OS.PC, OS.NUM_OS);
00048 }
00049
00050 void Computer::draw() {
00051 ui.draw(net.pictures[type], x, y);
00052 if (os != OS.OFF)
00053 ui.draw(OS.os[os], x + OFFSET, y + OFFSET);
00054 }
00055
00056