1 | /* |
---|
2 | * ttyvaders Textmode shoot'em up |
---|
3 | * Copyright (c) 2002 Sam Hocevar <sam@zoy.org> |
---|
4 | * All Rights Reserved |
---|
5 | * |
---|
6 | * $Id: weapons.c,v 1.10 2002/12/22 23:01:35 sam Exp $ |
---|
7 | * |
---|
8 | * This program is free software; you can redistribute it and/or modify |
---|
9 | * it under the terms of the GNU General Public License as published by |
---|
10 | * the Free Software Foundation; either version 2 of the License, or |
---|
11 | * (at your option) any later version. |
---|
12 | * |
---|
13 | * This program is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | * GNU General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU General Public License |
---|
19 | * along with this program; if not, write to the Free Software |
---|
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
21 | */ |
---|
22 | |
---|
23 | #include <stdlib.h> |
---|
24 | |
---|
25 | #include "common.h" |
---|
26 | |
---|
27 | static void draw_bomb( int x, int y, int vx, int vy ); |
---|
28 | static void draw_nuke( int x, int y, int frame ); |
---|
29 | static void draw_beam( int x, int y, int frame ); |
---|
30 | static void draw_circle( int x, int y, int r, char c ); |
---|
31 | static void draw_fragbomb( int x, int y, int frame ); |
---|
32 | |
---|
33 | void init_weapons( game *g, weapons *wp ) |
---|
34 | { |
---|
35 | int i; |
---|
36 | |
---|
37 | for( i = 0; i < WEAPONS; i++ ) |
---|
38 | { |
---|
39 | wp->type[i] = WEAPON_NONE; |
---|
40 | } |
---|
41 | } |
---|
42 | |
---|
43 | void draw_weapons( game *g, weapons *wp ) |
---|
44 | { |
---|
45 | int i; |
---|
46 | |
---|
47 | for( i = 0; i < WEAPONS; i++ ) |
---|
48 | { |
---|
49 | switch( wp->type[i] ) |
---|
50 | { |
---|
51 | case WEAPON_LASER: |
---|
52 | gfx_color( WHITE ); |
---|
53 | gfx_goto( wp->x[i] >> 4, wp->y[i] >> 4 ); |
---|
54 | gfx_putchar( '|' ); |
---|
55 | gfx_color( CYAN ); |
---|
56 | gfx_goto( wp->x[i] >> 4, (wp->y[i] >> 4) + 1 ); |
---|
57 | gfx_putchar( '|' ); |
---|
58 | break; |
---|
59 | case WEAPON_SEEKER: |
---|
60 | gfx_color( CYAN ); |
---|
61 | gfx_goto( wp->x3[i] >> 4, wp->y3[i] >> 4 ); |
---|
62 | gfx_putchar( '.' ); |
---|
63 | gfx_goto( wp->x2[i] >> 4, wp->y2[i] >> 4 ); |
---|
64 | gfx_putchar( 'o' ); |
---|
65 | gfx_color( WHITE ); |
---|
66 | gfx_goto( wp->x[i] >> 4, wp->y[i] >> 4 ); |
---|
67 | gfx_putchar( '@' ); |
---|
68 | break; |
---|
69 | case WEAPON_BOMB: |
---|
70 | gfx_color( GRAY ); |
---|
71 | gfx_goto( (wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4 ); |
---|
72 | gfx_putchar( '.' ); |
---|
73 | gfx_goto( (wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4 ); |
---|
74 | gfx_putchar( '.' ); |
---|
75 | gfx_goto( (wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4 ); |
---|
76 | gfx_putchar( '.' ); |
---|
77 | gfx_goto( wp->x3[i] >> 4, wp->y3[i] >> 4 ); |
---|
78 | gfx_putchar( '.' ); |
---|
79 | gfx_goto( wp->x2[i] >> 4, wp->y2[i] >> 4 ); |
---|
80 | gfx_putchar( '.' ); |
---|
81 | draw_bomb( wp->x[i] >> 4, wp->y[i] >> 4, wp->vx[i], wp->vy[i] ); |
---|
82 | break; |
---|
83 | case WEAPON_FRAGBOMB: |
---|
84 | draw_fragbomb( wp->x[i] >> 4, wp->y[i] >> 4, wp->n[i] ); |
---|
85 | break; |
---|
86 | case WEAPON_BEAM: |
---|
87 | draw_beam( wp->x[i] >> 4, wp->y[i] >> 4, wp->n[i] ); |
---|
88 | break; |
---|
89 | case WEAPON_NUKE: |
---|
90 | draw_nuke( wp->x[i] >> 4, wp->y[i] >> 4, wp->n[i] ); |
---|
91 | break; |
---|
92 | case WEAPON_LIGHTNING: |
---|
93 | case WEAPON_NONE: |
---|
94 | break; |
---|
95 | } |
---|
96 | } |
---|
97 | } |
---|
98 | |
---|
99 | void update_weapons( game *g, weapons *wp ) |
---|
100 | { |
---|
101 | int i, j, dist, xmin, ymin, dx, dy, xnew, ynew; |
---|
102 | |
---|
103 | for( i = 0; i < WEAPONS; i++ ) |
---|
104 | { |
---|
105 | switch( wp->type[i] ) |
---|
106 | { |
---|
107 | case WEAPON_LASER: |
---|
108 | wp->x[i] += wp->vx[i]; |
---|
109 | wp->y[i] += wp->vy[i]; |
---|
110 | if( wp->y[i] < 0 ) |
---|
111 | { |
---|
112 | wp->type[i] = WEAPON_NONE; |
---|
113 | } |
---|
114 | break; |
---|
115 | case WEAPON_BOMB: |
---|
116 | case WEAPON_SEEKER: |
---|
117 | /* Update tail */ |
---|
118 | wp->x3[i] = wp->x2[i]; |
---|
119 | wp->y3[i] = wp->y2[i]; |
---|
120 | |
---|
121 | wp->x2[i] = wp->x[i]; |
---|
122 | wp->y2[i] = wp->y[i]; |
---|
123 | |
---|
124 | wp->x[i] += wp->vx[i]; |
---|
125 | wp->y[i] += wp->vy[i]; |
---|
126 | |
---|
127 | if( wp->y[i] < 0 ) |
---|
128 | { |
---|
129 | wp->type[i] = WEAPON_NONE; |
---|
130 | break; |
---|
131 | } |
---|
132 | |
---|
133 | if( wp->n[i] < 0 ) |
---|
134 | { |
---|
135 | /* Stop updating direction */ |
---|
136 | break; |
---|
137 | } |
---|
138 | |
---|
139 | wp->n[i]--; |
---|
140 | |
---|
141 | /* Estimate our position in 2 frames */ |
---|
142 | xnew = wp->x[i] + 4 * wp->vx[i]; |
---|
143 | ynew = wp->y[i] + 4 * wp->vy[i]; |
---|
144 | |
---|
145 | xmin = xnew; |
---|
146 | ymin = - (g->h << 4); |
---|
147 | dist = (xnew - xmin) * (xnew - xmin) |
---|
148 | + 4 * (ynew - ymin) * (ynew - ymin); |
---|
149 | |
---|
150 | /* Find the nearest alien */ |
---|
151 | for( j = 0; j < ALIENS; j++ ) |
---|
152 | { |
---|
153 | if( g->al->type[j] != ALIEN_NONE ) |
---|
154 | { |
---|
155 | int alx = g->al->x[j] << 4; |
---|
156 | int aly = g->al->y[j] << 4; |
---|
157 | int new = (xnew - alx) * (xnew - alx) |
---|
158 | + 4 * (ynew - aly) * (ynew - aly); |
---|
159 | if( new <= dist ) |
---|
160 | { |
---|
161 | dist = new; |
---|
162 | xmin = alx; |
---|
163 | ymin = aly; |
---|
164 | } |
---|
165 | } |
---|
166 | } |
---|
167 | |
---|
168 | /* Find our new direction */ |
---|
169 | dx = xmin - wp->x[i]; |
---|
170 | dy = ymin - wp->y[i]; |
---|
171 | |
---|
172 | /* Normalize and update speed */ |
---|
173 | if( dx | dy ) |
---|
174 | { |
---|
175 | int norm = r00t( dx * dx + dy * dy ); |
---|
176 | |
---|
177 | wp->vx[i] = (7 * wp->vx[i] + (dx * 48) / norm ) / 8; |
---|
178 | wp->vy[i] = (7 * wp->vy[i] + (dy * 24) / norm ) / 8; |
---|
179 | } |
---|
180 | break; |
---|
181 | |
---|
182 | case WEAPON_FRAGBOMB: |
---|
183 | /* If n was set to -1, the fragbomb just exploded */ |
---|
184 | if( wp->n[i] == -1 ) |
---|
185 | { |
---|
186 | int coords[] = |
---|
187 | { |
---|
188 | 24, 0, -24, 0, 0, 24, 0, -24, |
---|
189 | 24, 8, -24, 8, 24, -8, -24, -8, |
---|
190 | 16, 16, -16, 16, 16, -16, -16, -16 |
---|
191 | }; |
---|
192 | |
---|
193 | for( j = 0; j < 12; j++ ) |
---|
194 | { |
---|
195 | add_weapon( g, g->wp, wp->x[i] + coords[2*j], wp->y[i] + coords[2*j+1], coords[2*j], coords[2*j+1], WEAPON_SEEKER ); |
---|
196 | } |
---|
197 | |
---|
198 | wp->type[i] = WEAPON_NONE; |
---|
199 | } |
---|
200 | |
---|
201 | wp->x[i] += wp->vx[i]; |
---|
202 | wp->y[i] += wp->vy[i]; |
---|
203 | wp->n[i]++; |
---|
204 | if( wp->y[i] < 0 ) |
---|
205 | { |
---|
206 | wp->type[i] = WEAPON_NONE; |
---|
207 | } |
---|
208 | break; |
---|
209 | |
---|
210 | case WEAPON_BEAM: |
---|
211 | wp->x[i] = (g->p->x + 2) << 4; |
---|
212 | wp->y[i] = g->p->y << 4; |
---|
213 | wp->n[i]--; |
---|
214 | if( wp->n[i] < 0 ) |
---|
215 | { |
---|
216 | wp->type[i] = WEAPON_NONE; |
---|
217 | } |
---|
218 | break; |
---|
219 | case WEAPON_NUKE: |
---|
220 | wp->n[i]--; |
---|
221 | if( wp->n[i] < 0 ) |
---|
222 | { |
---|
223 | wp->type[i] = WEAPON_NONE; |
---|
224 | } |
---|
225 | break; |
---|
226 | case WEAPON_LIGHTNING: |
---|
227 | case WEAPON_NONE: |
---|
228 | break; |
---|
229 | } |
---|
230 | } |
---|
231 | } |
---|
232 | |
---|
233 | void add_weapon( game *g, weapons *wp, int x, int y, int vx, int vy, int type ) |
---|
234 | { |
---|
235 | int i; |
---|
236 | |
---|
237 | for( i = 0; i < WEAPONS; i++ ) |
---|
238 | { |
---|
239 | if( wp->type[i] == WEAPON_NONE ) |
---|
240 | { |
---|
241 | wp->x[i] = x; |
---|
242 | wp->y[i] = y; |
---|
243 | wp->vx[i] = vx; |
---|
244 | wp->vy[i] = vy; |
---|
245 | wp->type[i] = type; |
---|
246 | wp->n[i] = 0; |
---|
247 | switch( type ) |
---|
248 | { |
---|
249 | case WEAPON_LASER: |
---|
250 | break; |
---|
251 | case WEAPON_FRAGBOMB: |
---|
252 | break; |
---|
253 | case WEAPON_SEEKER: |
---|
254 | case WEAPON_BOMB: |
---|
255 | wp->x2[i] = x; |
---|
256 | wp->y2[i] = y; |
---|
257 | wp->x3[i] = x; |
---|
258 | wp->y3[i] = y; |
---|
259 | wp->n[i] = 20; |
---|
260 | break; |
---|
261 | case WEAPON_BEAM: |
---|
262 | wp->n[i] = 25; |
---|
263 | break; |
---|
264 | case WEAPON_NUKE: |
---|
265 | wp->n[i] = 25; |
---|
266 | break; |
---|
267 | case WEAPON_NONE: |
---|
268 | break; |
---|
269 | } |
---|
270 | break; |
---|
271 | } |
---|
272 | } |
---|
273 | } |
---|
274 | |
---|
275 | static void draw_bomb( int x, int y, int vx, int vy ) |
---|
276 | { |
---|
277 | vy *= 2; |
---|
278 | gfx_color( CYAN ); |
---|
279 | |
---|
280 | if( vx > vy ) |
---|
281 | { |
---|
282 | if( vx > -vy ) /* right quarter */ |
---|
283 | { |
---|
284 | if( vy > vx/4 ) |
---|
285 | { |
---|
286 | /* -1pi/6 */ |
---|
287 | gfx_goto( x-4, y-1 ); |
---|
288 | gfx_putstr( "/`-." ); |
---|
289 | gfx_goto( x-4, y ); |
---|
290 | gfx_putstr( "`-._\\" ); |
---|
291 | gfx_color( WHITE ); |
---|
292 | gfx_goto( x-1, y ); |
---|
293 | gfx_putstr( "_\\" ); |
---|
294 | gfx_goto( x, y+1 ); |
---|
295 | gfx_putchar( '`' ); |
---|
296 | } |
---|
297 | else if( vy < -vx/4 ) |
---|
298 | { |
---|
299 | /* 1pi/6 */ |
---|
300 | gfx_goto( x-4, y ); |
---|
301 | gfx_putstr( ",-' " ); |
---|
302 | gfx_goto( x-4, y+1 ); |
---|
303 | gfx_putstr( "\\,-'" ); |
---|
304 | gfx_color( WHITE ); |
---|
305 | gfx_goto( x-1, y-1 ); |
---|
306 | gfx_putstr( "_," ); |
---|
307 | gfx_goto( x, y ); |
---|
308 | gfx_putchar( '/' ); |
---|
309 | } |
---|
310 | else |
---|
311 | { |
---|
312 | /* 0pi/6 */ |
---|
313 | gfx_goto( x-4, y-1 ); |
---|
314 | gfx_putstr( "____" ); |
---|
315 | gfx_goto( x-5, y ); |
---|
316 | gfx_putstr( "|____" ); |
---|
317 | gfx_color( WHITE ); |
---|
318 | gfx_goto( x, y ); |
---|
319 | gfx_putchar( '>' ); |
---|
320 | } |
---|
321 | } |
---|
322 | else /* top quarter */ |
---|
323 | { |
---|
324 | if( vx > -vy/4 ) |
---|
325 | { |
---|
326 | /* 2pi/6 */ |
---|
327 | gfx_goto( x-2, y ); |
---|
328 | gfx_putstr( "/ " ); |
---|
329 | gfx_goto( x-3, y+1 ); |
---|
330 | gfx_putstr( "/ /" ); |
---|
331 | gfx_goto( x-3, y+2 ); |
---|
332 | gfx_putstr( "`'" ); |
---|
333 | gfx_color( WHITE ); |
---|
334 | gfx_goto( x-1, y-1 ); |
---|
335 | gfx_putstr( "_," ); |
---|
336 | gfx_goto( x, y ); |
---|
337 | gfx_putchar( '|' ); |
---|
338 | } |
---|
339 | else if( vx < vy/4 ) |
---|
340 | { |
---|
341 | /* 4pi/6 */ |
---|
342 | gfx_goto( x+1, y ); |
---|
343 | gfx_putstr( " \\" ); |
---|
344 | gfx_goto( x+1, y+1 ); |
---|
345 | gfx_putstr( "\\ \\" ); |
---|
346 | gfx_goto( x+2, y+2 ); |
---|
347 | gfx_putstr( "`'" ); |
---|
348 | gfx_color( WHITE ); |
---|
349 | gfx_goto( x, y-1 ); |
---|
350 | gfx_putstr( "._" ); |
---|
351 | gfx_goto( x, y ); |
---|
352 | gfx_putchar( '|' ); |
---|
353 | } |
---|
354 | else |
---|
355 | { |
---|
356 | /* 3pi/6 */ |
---|
357 | gfx_goto( x-1, y+1 ); |
---|
358 | gfx_putstr( "| |" ); |
---|
359 | gfx_goto( x-1, y+2 ); |
---|
360 | gfx_putstr( "|_|" ); |
---|
361 | gfx_color( WHITE ); |
---|
362 | gfx_goto( x-1, y ); |
---|
363 | gfx_putstr( ",^." ); |
---|
364 | } |
---|
365 | } |
---|
366 | } |
---|
367 | else |
---|
368 | { |
---|
369 | if( vx > -vy ) /* bottom quarter */ |
---|
370 | { |
---|
371 | if( vx > vy/4 ) |
---|
372 | { |
---|
373 | /* -2pi/6 */ |
---|
374 | gfx_goto( x-2, y-2 ); |
---|
375 | gfx_putstr( ",." ); |
---|
376 | gfx_goto( x-2, y-1 ); |
---|
377 | gfx_putstr( "\\ \\" ); |
---|
378 | gfx_goto( x-1, y ); |
---|
379 | gfx_putchar( '\\' ); |
---|
380 | gfx_color( WHITE ); |
---|
381 | gfx_goto( x, y ); |
---|
382 | gfx_putstr( "_|" ); |
---|
383 | } |
---|
384 | else if( vx < -vy/4 ) |
---|
385 | { |
---|
386 | /* -4pi/6 */ |
---|
387 | gfx_goto( x+1, y-2 ); |
---|
388 | gfx_putstr( ",." ); |
---|
389 | gfx_goto( x, y-1 ); |
---|
390 | gfx_putstr( "/ /" ); |
---|
391 | gfx_goto( x+1, y ); |
---|
392 | gfx_putchar( '/' ); |
---|
393 | gfx_color( WHITE ); |
---|
394 | gfx_goto( x-1, y ); |
---|
395 | gfx_putstr( "|_/" ); |
---|
396 | } |
---|
397 | else |
---|
398 | { |
---|
399 | /* -3pi/6 */ |
---|
400 | gfx_goto( x, y-3 ); |
---|
401 | gfx_putchar( '_' ); |
---|
402 | gfx_goto( x-1, y-2 ); |
---|
403 | gfx_putstr( "| |" ); |
---|
404 | gfx_goto( x-1, y-1 ); |
---|
405 | gfx_putstr( "| |" ); |
---|
406 | gfx_color( WHITE ); |
---|
407 | gfx_goto( x-1, y ); |
---|
408 | gfx_putstr( "`v'" ); |
---|
409 | } |
---|
410 | } |
---|
411 | else /* left quarter */ |
---|
412 | { |
---|
413 | if( vy > -vx/4 ) |
---|
414 | { |
---|
415 | /* -5pi/6 */ |
---|
416 | gfx_goto( x+1, y-1 ); |
---|
417 | gfx_putstr( ",-'\\" ); |
---|
418 | gfx_goto( x+2, y ); |
---|
419 | gfx_putstr( ",-'" ); |
---|
420 | gfx_goto( x, y+1 ); |
---|
421 | gfx_putchar( '\'' ); |
---|
422 | gfx_color( WHITE ); |
---|
423 | gfx_goto( x, y ); |
---|
424 | gfx_putstr( "/_" ); |
---|
425 | } |
---|
426 | else if( vy < vx/4 ) |
---|
427 | { |
---|
428 | /* 5pi/6 */ |
---|
429 | gfx_goto( x+1, y ); |
---|
430 | gfx_putstr( " `-." ); |
---|
431 | gfx_goto( x+1, y+1 ); |
---|
432 | gfx_putstr( "`-./" ); |
---|
433 | gfx_color( WHITE ); |
---|
434 | gfx_goto( x, y-1 ); |
---|
435 | gfx_putstr( "._" ); |
---|
436 | gfx_goto( x, y ); |
---|
437 | gfx_putchar( '\\' ); |
---|
438 | } |
---|
439 | else |
---|
440 | { |
---|
441 | /* 6pi/6 */ |
---|
442 | gfx_goto( x+1, y-1 ); |
---|
443 | gfx_putstr( "____" ); |
---|
444 | gfx_goto( x+1, y ); |
---|
445 | gfx_putstr( "____|" ); |
---|
446 | gfx_color( WHITE ); |
---|
447 | gfx_goto( x, y ); |
---|
448 | gfx_putchar( '<' ); |
---|
449 | } |
---|
450 | } |
---|
451 | } |
---|
452 | } |
---|
453 | |
---|
454 | static void draw_fragbomb( int x, int y, int frame ) |
---|
455 | { |
---|
456 | gfx_color( WHITE ); |
---|
457 | |
---|
458 | gfx_color( frame & 1 ? CYAN : WHITE ); |
---|
459 | gfx_goto( x-2, y ); |
---|
460 | gfx_putstr( "( )" ); |
---|
461 | gfx_goto( x-1, y+1 ); |
---|
462 | gfx_putstr( "`--'" ); |
---|
463 | |
---|
464 | gfx_color( frame & 1 ? WHITE : CYAN ); |
---|
465 | gfx_goto( x-1, y-1 ); |
---|
466 | gfx_putstr( ",--." ); |
---|
467 | gfx_goto( x, y ); |
---|
468 | gfx_putstr( "'," ); |
---|
469 | |
---|
470 | switch( frame % 4 ) |
---|
471 | { |
---|
472 | case 0: |
---|
473 | gfx_color( CYAN ); |
---|
474 | gfx_goto( x, y + 2 ); |
---|
475 | gfx_putchar( 'O' ); |
---|
476 | gfx_goto( x + 2, y + 2 ); |
---|
477 | gfx_putchar( 'o' ); |
---|
478 | gfx_goto( x + 1, y + 3 ); |
---|
479 | gfx_putchar( 'o' ); |
---|
480 | gfx_color( GRAY ); |
---|
481 | gfx_goto( x - 1, y + 3 ); |
---|
482 | gfx_putchar( '°' ); |
---|
483 | gfx_goto( x + 2, y + 4 ); |
---|
484 | gfx_putchar( '°' ); |
---|
485 | gfx_goto( x, y + 4 ); |
---|
486 | gfx_putchar( '.' ); |
---|
487 | gfx_goto( x + 1, y + 5 ); |
---|
488 | gfx_putchar( '.' ); |
---|
489 | break; |
---|
490 | case 1: |
---|
491 | gfx_color( CYAN ); |
---|
492 | //gfx_goto( x, y + 1 ); |
---|
493 | //gfx_putchar( 'O' ); |
---|
494 | gfx_goto( x + 1, y + 2 ); |
---|
495 | gfx_putchar( 'O' ); |
---|
496 | gfx_goto( x, y + 3 ); |
---|
497 | gfx_putchar( 'o' ); |
---|
498 | gfx_color( GRAY ); |
---|
499 | gfx_goto( x + 2, y + 3 ); |
---|
500 | gfx_putchar( '°' ); |
---|
501 | gfx_goto( x + 1, y + 4 ); |
---|
502 | gfx_putchar( '°' ); |
---|
503 | gfx_goto( x - 1, y + 4 ); |
---|
504 | gfx_putchar( '.' ); |
---|
505 | gfx_goto( x + 2, y + 5 ); |
---|
506 | gfx_putchar( '.' ); |
---|
507 | break; |
---|
508 | case 2: |
---|
509 | gfx_color( CYAN ); |
---|
510 | //gfx_goto( x - 1, y + 1 ); |
---|
511 | //gfx_putchar( 'O' ); |
---|
512 | gfx_goto( x + 2, y + 2 ); |
---|
513 | gfx_putchar( 'O' ); |
---|
514 | gfx_goto( x, y + 2 ); |
---|
515 | gfx_putchar( 'o' ); |
---|
516 | gfx_goto( x + 1, y + 3 ); |
---|
517 | gfx_putchar( 'o' ); |
---|
518 | gfx_color( GRAY ); |
---|
519 | gfx_goto( x, y + 4 ); |
---|
520 | gfx_putchar( '°' ); |
---|
521 | gfx_goto( x + 2, y + 4 ); |
---|
522 | gfx_putchar( '.' ); |
---|
523 | gfx_goto( x + 1, y + 5 ); |
---|
524 | gfx_putchar( '.' ); |
---|
525 | break; |
---|
526 | case 3: |
---|
527 | gfx_color( CYAN ); |
---|
528 | //gfx_goto( x + 2, y + 1 ); |
---|
529 | //gfx_putchar( 'O' ); |
---|
530 | gfx_goto( x + 1, y + 2 ); |
---|
531 | gfx_putchar( 'O' ); |
---|
532 | gfx_goto( x - 1, y + 2 ); |
---|
533 | gfx_putchar( 'o' ); |
---|
534 | gfx_goto( x + 2, y + 3 ); |
---|
535 | gfx_putchar( 'o' ); |
---|
536 | gfx_color( GRAY ); |
---|
537 | gfx_goto( x, y + 3 ); |
---|
538 | gfx_putchar( '°' ); |
---|
539 | gfx_goto( x + 1, y + 4 ); |
---|
540 | gfx_putchar( '°' ); |
---|
541 | gfx_goto( x, y + 5 ); |
---|
542 | gfx_putchar( '.' ); |
---|
543 | break; |
---|
544 | } |
---|
545 | } |
---|
546 | |
---|
547 | static void draw_beam( int x, int y, int frame ) |
---|
548 | { |
---|
549 | int r = (29 - frame) * (29 - frame) / 8; |
---|
550 | int i; |
---|
551 | |
---|
552 | switch( frame ) |
---|
553 | { |
---|
554 | case 24: |
---|
555 | gfx_color( WHITE ); |
---|
556 | gfx_goto( x, y-3 ); |
---|
557 | gfx_putstr( "__" ); |
---|
558 | gfx_goto( x-1, y-2 ); |
---|
559 | gfx_putchar( '\'' ); |
---|
560 | gfx_goto( x+2, y-2 ); |
---|
561 | gfx_putchar( '`' ); |
---|
562 | break; |
---|
563 | case 23: |
---|
564 | gfx_color( CYAN ); |
---|
565 | gfx_goto( x, y-3 ); |
---|
566 | gfx_putstr( "__" ); |
---|
567 | gfx_color( WHITE ); |
---|
568 | gfx_goto( x-2, y-2 ); |
---|
569 | gfx_putstr( "-'" ); |
---|
570 | gfx_goto( x+2, y-2 ); |
---|
571 | gfx_putstr( "`-" ); |
---|
572 | break; |
---|
573 | case 22: |
---|
574 | gfx_color( CYAN ); |
---|
575 | gfx_goto( x, y-3 ); |
---|
576 | gfx_putstr( "__" ); |
---|
577 | gfx_goto( x-1, y-2 ); |
---|
578 | gfx_putchar( '\'' ); |
---|
579 | gfx_goto( x+2, y-2 ); |
---|
580 | gfx_putchar( '`' ); |
---|
581 | gfx_color( WHITE ); |
---|
582 | gfx_goto( x-3, y-2 ); |
---|
583 | gfx_putstr( ",-" ); |
---|
584 | gfx_goto( x+3, y-2 ); |
---|
585 | gfx_putstr( "-." ); |
---|
586 | break; |
---|
587 | case 21: |
---|
588 | gfx_color( CYAN ); |
---|
589 | gfx_goto( x-1, y-3 ); |
---|
590 | gfx_putstr( "____" ); |
---|
591 | gfx_goto( x-2, y-2 ); |
---|
592 | gfx_putchar( '\'' ); |
---|
593 | gfx_goto( x+3, y-2 ); |
---|
594 | gfx_putchar( '`' ); |
---|
595 | gfx_color( WHITE ); |
---|
596 | gfx_goto( x-4, y-2 ); |
---|
597 | gfx_putstr( ",-" ); |
---|
598 | gfx_goto( x+4, y-2 ); |
---|
599 | gfx_putstr( "-." ); |
---|
600 | break; |
---|
601 | case 20: |
---|
602 | gfx_color( WHITE ); |
---|
603 | gfx_goto( x, y-3 ); |
---|
604 | gfx_putstr( "%%" ); |
---|
605 | gfx_goto( x-4, y-2 ); |
---|
606 | gfx_putchar( ',' ); |
---|
607 | gfx_goto( x+5, y-2 ); |
---|
608 | gfx_putchar( '.' ); |
---|
609 | gfx_color( CYAN ); |
---|
610 | gfx_goto( x-1, y-3 ); |
---|
611 | gfx_putchar( ':' ); |
---|
612 | gfx_goto( x+2, y-3 ); |
---|
613 | gfx_putchar( ':' ); |
---|
614 | gfx_goto( x-3, y-2 ); |
---|
615 | gfx_putstr( "-'" ); |
---|
616 | gfx_goto( x+3, y-2 ); |
---|
617 | gfx_putstr( "`-" ); |
---|
618 | break; |
---|
619 | case 19: |
---|
620 | gfx_color( WHITE ); |
---|
621 | gfx_goto( x, y-4 ); |
---|
622 | gfx_putstr( "%%" ); |
---|
623 | gfx_goto( x, y-3 ); |
---|
624 | gfx_putstr( "##" ); |
---|
625 | gfx_color( CYAN ); |
---|
626 | gfx_goto( x-1, y-4 ); |
---|
627 | gfx_putchar( ':' ); |
---|
628 | gfx_goto( x+2, y-4 ); |
---|
629 | gfx_putchar( ':' ); |
---|
630 | gfx_goto( x-1, y-3 ); |
---|
631 | gfx_putchar( '%' ); |
---|
632 | gfx_goto( x+2, y-3 ); |
---|
633 | gfx_putchar( '%' ); |
---|
634 | gfx_goto( x-4, y-2 ); |
---|
635 | gfx_putstr( ",-'" ); |
---|
636 | gfx_goto( x+3, y-2 ); |
---|
637 | gfx_putstr( "`-." ); |
---|
638 | gfx_color( BLUE ); |
---|
639 | gfx_goto( x-2, y-3 ); |
---|
640 | gfx_putchar( ':' ); |
---|
641 | gfx_goto( x+3, y-3 ); |
---|
642 | gfx_putchar( ':' ); |
---|
643 | break; |
---|
644 | case 18: |
---|
645 | default: |
---|
646 | r = (18 - frame) * (18 - frame); |
---|
647 | gfx_color( WHITE ); |
---|
648 | gfx_goto( x-1, y-5-r ); |
---|
649 | gfx_putstr( ":%%:" ); |
---|
650 | gfx_goto( x-1, y-4-r ); |
---|
651 | gfx_putstr( "%##%" ); |
---|
652 | gfx_color( CYAN ); |
---|
653 | gfx_goto( x-2, y-4-r ); |
---|
654 | gfx_putchar( ':' ); |
---|
655 | gfx_goto( x+3, y-4-r ); |
---|
656 | gfx_putchar( ':' ); |
---|
657 | gfx_goto( x-2, y-2 ); |
---|
658 | gfx_putchar( '\'' ); |
---|
659 | gfx_goto( x+3, y-2 ); |
---|
660 | gfx_putchar( '`' ); |
---|
661 | gfx_color( BLUE ); |
---|
662 | gfx_goto( x-3, y-2 ); |
---|
663 | gfx_putchar( ':' ); |
---|
664 | gfx_goto( x+4, y-2 ); |
---|
665 | gfx_putchar( ':' ); |
---|
666 | for( i = 0; i <= r; i++ ) |
---|
667 | { |
---|
668 | gfx_color( WHITE ); |
---|
669 | gfx_goto( x-1, y-3-i ); |
---|
670 | gfx_putstr( (i+frame) % 5 ? "####" : "%%%%" ); |
---|
671 | gfx_color( CYAN ); |
---|
672 | gfx_goto( x-2, y-3-i ); |
---|
673 | gfx_putchar( '%' ); |
---|
674 | gfx_goto( x+3, y-3-i ); |
---|
675 | gfx_putchar( '%' ); |
---|
676 | gfx_color( BLUE ); |
---|
677 | gfx_goto( x-3, y-3-i ); |
---|
678 | gfx_putchar( ':' ); |
---|
679 | gfx_goto( x+4, y-3-i ); |
---|
680 | gfx_putchar( ':' ); |
---|
681 | } |
---|
682 | break; |
---|
683 | } |
---|
684 | } |
---|
685 | |
---|
686 | static void draw_nuke( int x, int y, int frame ) |
---|
687 | { |
---|
688 | int r = (29 - frame) * (29 - frame) / 8; |
---|
689 | |
---|
690 | /* Lots of duplicate pixels, but we don't care */ |
---|
691 | gfx_color( BLUE ); |
---|
692 | draw_circle( x, y, r++, ':' ); |
---|
693 | gfx_color( CYAN ); |
---|
694 | draw_circle( x, y, r++, '%' ); |
---|
695 | gfx_color( WHITE ); |
---|
696 | draw_circle( x, y, r++, '#' ); |
---|
697 | draw_circle( x, y, r++, '#' ); |
---|
698 | } |
---|
699 | |
---|
700 | static void draw_circle( int x, int y, int r, char c ) |
---|
701 | { |
---|
702 | int test, dx, dy; |
---|
703 | |
---|
704 | /* Optimized Bresenham. Kick ass. */ |
---|
705 | for( test = 0, dx = 0, dy = r ; dx <= dy ; dx++ ) |
---|
706 | { |
---|
707 | gfx_putcharTO( x + dx, y + dy / 2, c ); |
---|
708 | gfx_putcharTO( x - dx, y + dy / 2, c ); |
---|
709 | gfx_putcharTO( x + dx, y - dy / 2, c ); |
---|
710 | gfx_putcharTO( x - dx, y - dy / 2, c ); |
---|
711 | |
---|
712 | gfx_putcharTO( x + dy, y + dx / 2, c ); |
---|
713 | gfx_putcharTO( x - dy, y + dx / 2, c ); |
---|
714 | gfx_putcharTO( x + dy, y - dx / 2, c ); |
---|
715 | gfx_putcharTO( x - dy, y - dx / 2, c ); |
---|
716 | |
---|
717 | test += test > 0 ? dx - dy-- : dx; |
---|
718 | } |
---|
719 | } |
---|
720 | |
---|