3
void Monster::get_border() {
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);
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;
15
/* Adds a bill to the in state*/
16
void Monster::enter(){
19
x = target_x; y=target_y;
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--;
31
/* Moves bill toward his target - returns whether or not he moved */
32
int Monster::move (int mode) {
33
int xdist = target_x - x;
34
int ydist = target_y - y;
35
int step = step_size(game.level);
37
int signx = xdist >= 0 ? 1 : -1;
38
int signy = ydist >= 0 ? 1 : -1;
41
if (!xdist && !ydist) return 0;
42
else if (xdist<step && ydist<step) {
47
dx = (xdist*step*signx)/(xdist+ydist);
48
dy = (ydist*step*signy)/(xdist+ydist);
51
case FAST: dx = 5*dx/4; dy = 5*dy/4; break;
63
void Monster::draw() {
67
case DYING: draw_std(); break;
68
case AT: draw_at(); break;
69
case STRAY: draw_stray(); break;
74
/* Update Bill's position */
75
void Monster::update_in() {
76
int moved = move(SLOW);
77
if (!moved && (net.computers[target_c].os != OS.WINGDOWS)
78
&& !(net.computers[target_c].busy))
80
net.computers[target_c].busy=1;
89
i=game.RAND(0, net.units-1);
90
} while (i == target_c);
92
target_x = net.computers[target_c].x + net.width-XOFFSET;
93
target_y = net.computers[target_c].y + YOFFSET;
97
y_offset+=(8*(index%2)-4);
100
/* Update Bill standing at a computer */
101
void Monster::update_at() {
103
if (index==0 && net.computers[target_c].os == OS.OFF) {
105
sys = net.computers[target_c].find_stray();
106
if (sys<0) cargo = -1;
108
cargo = bill.list[sys].cargo;
109
bill.list[sys].state = OFF;
120
net.computers[target_c].busy=0;
123
y_offset = bill.height - OS.height;
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;
131
if (net.computers[target_c].os != OS.OFF) {
132
net.base--; net.off++;
133
cargo = net.computers[target_c].os;
138
net.computers[target_c].os = OS.OFF;
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++;
151
case 12 : x += 11; x_offset -=11;
155
/* Updates Bill fleeing with his ill gotten gain */
156
void Monster::update_out() {
157
if (game.INTERSECT(x, y, bill.width, bill.height, 0, 0, game.scrwidth,
163
y_offset+=(8*(index%2)-4);
167
bill.on_screen--; bill.off_screen++;
172
/* Updates Bill who is dying */
173
void Monster::update_dying() {
174
if (index < bill.DCELS-1){
175
y_offset += (index*GRAVITY);
180
if (cargo<0 || cargo == OS.WINGDOWS) state = OFF;
186
void Monster::update() {
188
case IN: update_in(); break;
189
case AT: update_at(); break;
190
case OUT: update_out(); break;
191
case DYING: update_dying(); break;
196
int Monster::clicked(int locx, int locy) {
197
return (locx>x && locx<x+bill.width && locy>y && locy<y+bill.height);
200
int Monster::clickedstray(int locx, int locy) {
201
return (locx>x && locx<x+OS.width && locy>y && locy<y+OS.height);
204
int Monster::step_size(unsigned int lev) {
205
return game.MIN(14+lev, 18);
208
void Monster::draw_std() {
210
ui.draw(OS.os[cargo], x + x_offset, y + y_offset);
211
ui.draw(cels[index], x, y);
214
void Monster::draw_at() {
215
if (index>6 && index<12)
216
ui.draw(OS.os[0], x + sx, y + sy);
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);
223
void Monster::draw_stray() {
224
if (game.grabbed==-1 || x != bill.list[game.grabbed].x)
225
ui.draw(OS.os[cargo], x, y);