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.11 2002/12/22 23:39:15 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 next frames */ |
---|
142 | xnew = wp->x[i] + wp->vx[i]; |
---|
143 | ynew = wp->y[i] + 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 direction */ |
---|
173 | if( dx | dy ) |
---|
174 | { |
---|
175 | int norm = r00t( dx * dx + 4 * dy * dy ); |
---|
176 | dx = dx * 32 / norm; |
---|
177 | dy = dy * 32 / norm; |
---|
178 | } |
---|
179 | |
---|
180 | /* Find our new speed */ |
---|
181 | dx = (dx + 3 * wp->vx[i]) / 4; |
---|
182 | dy = (dy + 3 * wp->vy[i]) / 4; |
---|
183 | |
---|
184 | /* Normalize speed */ |
---|
185 | if( dx | dy ) |
---|
186 | { |
---|
187 | int norm = r00t( dx * dx + 4 * dy * dy ); |
---|
188 | wp->vx[i] = dx * 32 / norm; |
---|
189 | wp->vy[i] = dy * 32 / norm; |
---|
190 | } |
---|
191 | |
---|
192 | break; |
---|
193 | |
---|
194 | case WEAPON_FRAGBOMB: |
---|
195 | /* If n was set to -1, the fragbomb just exploded */ |
---|
196 | if( wp->n[i] == -1 ) |
---|
197 | { |
---|
198 | int coords[] = |
---|
199 | { |
---|
200 | 32, 0, -32, 0, 0, 16, 0, -16, |
---|
201 | 24, 12, -24, 12, 24, -12, -24, -12, |
---|
202 | 28, 8, -28, 8, 28, -8, -28, -8, |
---|
203 | 16, 14, -16, 14, 16, -14, -16, -14 |
---|
204 | }; |
---|
205 | |
---|
206 | for( j = 0 ; j < sizeof(coords) / sizeof(int) ; j += 2 ) |
---|
207 | { |
---|
208 | add_weapon( g, g->wp, wp->x[i] + coords[j], wp->y[i] + coords[j+1], coords[j], coords[j+1], WEAPON_SEEKER ); |
---|
209 | } |
---|
210 | |
---|
211 | wp->type[i] = WEAPON_NONE; |
---|
212 | } |
---|
213 | |
---|
214 | wp->x[i] += wp->vx[i]; |
---|
215 | wp->y[i] += wp->vy[i]; |
---|
216 | wp->n[i]++; |
---|
217 | if( wp->y[i] < 0 ) |
---|
218 | { |
---|
219 | wp->type[i] = WEAPON_NONE; |
---|
220 | } |
---|
221 | break; |
---|
222 | |
---|
223 | case WEAPON_BEAM: |
---|
224 | wp->x[i] = (g->p->x + 2) << 4; |
---|
225 | wp->y[i] = g->p->y << 4; |
---|
226 | wp->n[i]--; |
---|
227 | if( wp->n[i] < 0 ) |
---|
228 | { |
---|
229 | wp->type[i] = WEAPON_NONE; |
---|
230 | } |
---|
231 | break; |
---|
232 | case WEAPON_NUKE: |
---|
233 | wp->n[i]--; |
---|
234 | if( wp->n[i] < 0 ) |
---|
235 | { |
---|
236 | wp->type[i] = WEAPON_NONE; |
---|
237 | } |
---|
238 | break; |
---|
239 | case WEAPON_LIGHTNING: |
---|
240 | case WEAPON_NONE: |
---|
241 | break; |
---|
242 | } |
---|
243 | } |
---|
244 | } |
---|
245 | |
---|
246 | void add_weapon( game *g, weapons *wp, int x, int y, int vx, int vy, int type ) |
---|
247 | { |
---|
248 | int i; |
---|
249 | |
---|
250 | for( i = 0; i < WEAPONS; i++ ) |
---|
251 | { |
---|
252 | if( wp->type[i] == WEAPON_NONE ) |
---|
253 | { |
---|
254 | wp->x[i] = x; |
---|
255 | wp->y[i] = y; |
---|
256 | wp->vx[i] = vx; |
---|
257 | wp->vy[i] = vy; |
---|
258 | wp->type[i] = type; |
---|
259 | wp->n[i] = 0; |
---|
260 | switch( type ) |
---|
261 | { |
---|
262 | case WEAPON_LASER: |
---|
263 | break; |
---|
264 | case WEAPON_FRAGBOMB: |
---|
265 | break; |
---|
266 | case WEAPON_SEEKER: |
---|
267 | case WEAPON_BOMB: |
---|
268 | wp->x2[i] = x; |
---|
269 | wp->y2[i] = y; |
---|
270 | wp->x3[i] = x; |
---|
271 | wp->y3[i] = y; |
---|
272 | wp->n[i] = 20; |
---|
273 | break; |
---|
274 | case WEAPON_BEAM: |
---|
275 | wp->n[i] = 25; |
---|
276 | break; |
---|
277 | case WEAPON_NUKE: |
---|
278 | wp->n[i] = 25; |
---|
279 | break; |
---|
280 | case WEAPON_NONE: |
---|
281 | break; |
---|
282 | } |
---|
283 | break; |
---|
284 | } |
---|
285 | } |
---|
286 | } |
---|
287 | |
---|
288 | static void draw_bomb( int x, int y, int vx, int vy ) |
---|
289 | { |
---|
290 | vy *= 2; |
---|
291 | gfx_color( CYAN ); |
---|
292 | |
---|
293 | if( vx > vy ) |
---|
294 | { |
---|
295 | if( vx > -vy ) /* right quarter */ |
---|
296 | { |
---|
297 | if( vy > vx/4 ) |
---|
298 | { |
---|
299 | /* -1pi/6 */ |
---|
300 | gfx_goto( x-4, y-1 ); |
---|
301 | gfx_putstr( "/`-." ); |
---|
302 | gfx_goto( x-4, y ); |
---|
303 | gfx_putstr( "`-._\\" ); |
---|
304 | gfx_color( WHITE ); |
---|
305 | gfx_goto( x-1, y ); |
---|
306 | gfx_putstr( "_\\" ); |
---|
307 | gfx_goto( x, y+1 ); |
---|
308 | gfx_putchar( '`' ); |
---|
309 | } |
---|
310 | else if( vy < -vx/4 ) |
---|
311 | { |
---|
312 | /* 1pi/6 */ |
---|
313 | gfx_goto( x-4, y ); |
---|
314 | gfx_putstr( ",-' " ); |
---|
315 | gfx_goto( x-4, y+1 ); |
---|
316 | gfx_putstr( "\\,-'" ); |
---|
317 | gfx_color( WHITE ); |
---|
318 | gfx_goto( x-1, y-1 ); |
---|
319 | gfx_putstr( "_," ); |
---|
320 | gfx_goto( x, y ); |
---|
321 | gfx_putchar( '/' ); |
---|
322 | } |
---|
323 | else |
---|
324 | { |
---|
325 | /* 0pi/6 */ |
---|
326 | gfx_goto( x-4, y-1 ); |
---|
327 | gfx_putstr( "____" ); |
---|
328 | gfx_goto( x-5, y ); |
---|
329 | gfx_putstr( "|____" ); |
---|
330 | gfx_color( WHITE ); |
---|
331 | gfx_goto( x, y ); |
---|
332 | gfx_putchar( '>' ); |
---|
333 | } |
---|
334 | } |
---|
335 | else /* top quarter */ |
---|
336 | { |
---|
337 | if( vx > -vy/4 ) |
---|
338 | { |
---|
339 | /* 2pi/6 */ |
---|
340 | gfx_goto( x-2, y ); |
---|
341 | gfx_putstr( "/ " ); |
---|
342 | gfx_goto( x-3, y+1 ); |
---|
343 | gfx_putstr( "/ /" ); |
---|
344 | gfx_goto( x-3, y+2 ); |
---|
345 | gfx_putstr( "`'" ); |
---|
346 | gfx_color( WHITE ); |
---|
347 | gfx_goto( x-1, y-1 ); |
---|
348 | gfx_putstr( "_," ); |
---|
349 | gfx_goto( x, y ); |
---|
350 | gfx_putchar( '|' ); |
---|
351 | } |
---|
352 | else if( vx < vy/4 ) |
---|
353 | { |
---|
354 | /* 4pi/6 */ |
---|
355 | gfx_goto( x+1, y ); |
---|
356 | gfx_putstr( " \\" ); |
---|
357 | gfx_goto( x+1, y+1 ); |
---|
358 | gfx_putstr( "\\ \\" ); |
---|
359 | gfx_goto( x+2, y+2 ); |
---|
360 | gfx_putstr( "`'" ); |
---|
361 | gfx_color( WHITE ); |
---|
362 | gfx_goto( x, y-1 ); |
---|
363 | gfx_putstr( "._" ); |
---|
364 | gfx_goto( x, y ); |
---|
365 | gfx_putchar( '|' ); |
---|
366 | } |
---|
367 | else |
---|
368 | { |
---|
369 | /* 3pi/6 */ |
---|
370 | gfx_goto( x-1, y+1 ); |
---|
371 | gfx_putstr( "| |" ); |
---|
372 | gfx_goto( x-1, y+2 ); |
---|
373 | gfx_putstr( "|_|" ); |
---|
374 | gfx_color( WHITE ); |
---|
375 | gfx_goto( x-1, y ); |
---|
376 | gfx_putstr( ",^." ); |
---|
377 | } |
---|
378 | } |
---|
379 | } |
---|
380 | else |
---|
381 | { |
---|
382 | if( vx > -vy ) /* bottom quarter */ |
---|
383 | { |
---|
384 | if( vx > vy/4 ) |
---|
385 | { |
---|
386 | /* -2pi/6 */ |
---|
387 | gfx_goto( x-2, y-2 ); |
---|
388 | gfx_putstr( ",." ); |
---|
389 | gfx_goto( x-2, y-1 ); |
---|
390 | gfx_putstr( "\\ \\" ); |
---|
391 | gfx_goto( x-1, y ); |
---|
392 | gfx_putchar( '\\' ); |
---|
393 | gfx_color( WHITE ); |
---|
394 | gfx_goto( x, y ); |
---|
395 | gfx_putstr( "_|" ); |
---|
396 | } |
---|
397 | else if( vx < -vy/4 ) |
---|
398 | { |
---|
399 | /* -4pi/6 */ |
---|
400 | gfx_goto( x+1, y-2 ); |
---|
401 | gfx_putstr( ",." ); |
---|
402 | gfx_goto( x, y-1 ); |
---|
403 | gfx_putstr( "/ /" ); |
---|
404 | gfx_goto( x+1, y ); |
---|
405 | gfx_putchar( '/' ); |
---|
406 | gfx_color( WHITE ); |
---|
407 | gfx_goto( x-1, y ); |
---|
408 | gfx_putstr( "|_/" ); |
---|
409 | } |
---|
410 | else |
---|
411 | { |
---|
412 | /* -3pi/6 */ |
---|
413 | gfx_goto( x, y-3 ); |
---|
414 | gfx_putchar( '_' ); |
---|
415 | gfx_goto( x-1, y-2 ); |
---|
416 | gfx_putstr( "| |" ); |
---|
417 | gfx_goto( x-1, y-1 ); |
---|
418 | gfx_putstr( "| |" ); |
---|
419 | gfx_color( WHITE ); |
---|
420 | gfx_goto( x-1, y ); |
---|
421 | gfx_putstr( "`v'" ); |
---|
422 | } |
---|
423 | } |
---|
424 | else /* left quarter */ |
---|
425 | { |
---|
426 | if( vy > -vx/4 ) |
---|
427 | { |
---|
428 | /* -5pi/6 */ |
---|
429 | gfx_goto( x+1, y-1 ); |
---|
430 | gfx_putstr( ",-'\\" ); |
---|
431 | gfx_goto( x+2, y ); |
---|
432 | gfx_putstr( ",-'" ); |
---|
433 | gfx_goto( x, y+1 ); |
---|
434 | gfx_putchar( '\'' ); |
---|
435 | gfx_color( WHITE ); |
---|
436 | gfx_goto( x, y ); |
---|
437 | gfx_putstr( "/_" ); |
---|
438 | } |
---|
439 | else if( vy < vx/4 ) |
---|
440 | { |
---|
441 | /* 5pi/6 */ |
---|
442 | gfx_goto( x+1, y ); |
---|
443 | gfx_putstr( " `-." ); |
---|
444 | gfx_goto( x+1, y+1 ); |
---|
445 | gfx_putstr( "`-./" ); |
---|
446 | gfx_color( WHITE ); |
---|
447 | gfx_goto( x, y-1 ); |
---|
448 | gfx_putstr( "._" ); |
---|
449 | gfx_goto( x, y ); |
---|
450 | gfx_putchar( '\\' ); |
---|
451 | } |
---|
452 | else |
---|
453 | { |
---|
454 | /* 6pi/6 */ |
---|
455 | gfx_goto( x+1, y-1 ); |
---|
456 | gfx_putstr( "____" ); |
---|
457 | gfx_goto( x+1, y ); |
---|
458 | gfx_putstr( "____|" ); |
---|
459 | gfx_color( WHITE ); |
---|
460 | gfx_goto( x, y ); |
---|
461 | gfx_putchar( '<' ); |
---|
462 | } |
---|
463 | } |
---|
464 | } |
---|
465 | } |
---|
466 | |
---|
467 | static void draw_fragbomb( int x, int y, int frame ) |
---|
468 | { |
---|
469 | gfx_color( WHITE ); |
---|
470 | |
---|
471 | gfx_color( frame & 1 ? CYAN : WHITE ); |
---|
472 | gfx_goto( x-2, y ); |
---|
473 | gfx_putstr( "( )" ); |
---|
474 | gfx_goto( x-1, y+1 ); |
---|
475 | gfx_putstr( "`--'" ); |
---|
476 | |
---|
477 | gfx_color( frame & 1 ? WHITE : CYAN ); |
---|
478 | gfx_goto( x-1, y-1 ); |
---|
479 | gfx_putstr( ",--." ); |
---|
480 | gfx_goto( x, y ); |
---|
481 | gfx_putstr( "'," ); |
---|
482 | |
---|
483 | switch( frame % 4 ) |
---|
484 | { |
---|
485 | case 0: |
---|
486 | gfx_color( CYAN ); |
---|
487 | gfx_goto( x, y + 2 ); |
---|
488 | gfx_putchar( 'O' ); |
---|
489 | gfx_goto( x + 2, y + 2 ); |
---|
490 | gfx_putchar( 'o' ); |
---|
491 | gfx_goto( x + 1, y + 3 ); |
---|
492 | gfx_putchar( 'o' ); |
---|
493 | gfx_color( GRAY ); |
---|
494 | gfx_goto( x - 1, y + 3 ); |
---|
495 | gfx_putchar( '°' ); |
---|
496 | gfx_goto( x + 2, y + 4 ); |
---|
497 | gfx_putchar( '°' ); |
---|
498 | gfx_goto( x, y + 4 ); |
---|
499 | gfx_putchar( '.' ); |
---|
500 | gfx_goto( x + 1, y + 5 ); |
---|
501 | gfx_putchar( '.' ); |
---|
502 | break; |
---|
503 | case 1: |
---|
504 | gfx_color( CYAN ); |
---|
505 | //gfx_goto( x, y + 1 ); |
---|
506 | //gfx_putchar( 'O' ); |
---|
507 | gfx_goto( x + 1, y + 2 ); |
---|
508 | gfx_putchar( 'O' ); |
---|
509 | gfx_goto( x, y + 3 ); |
---|
510 | gfx_putchar( 'o' ); |
---|
511 | gfx_color( GRAY ); |
---|
512 | gfx_goto( x + 2, y + 3 ); |
---|
513 | gfx_putchar( '°' ); |
---|
514 | gfx_goto( x + 1, y + 4 ); |
---|
515 | gfx_putchar( '°' ); |
---|
516 | gfx_goto( x - 1, y + 4 ); |
---|
517 | gfx_putchar( '.' ); |
---|
518 | gfx_goto( x + 2, y + 5 ); |
---|
519 | gfx_putchar( '.' ); |
---|
520 | break; |
---|
521 | case 2: |
---|
522 | gfx_color( CYAN ); |
---|
523 | //gfx_goto( x - 1, y + 1 ); |
---|
524 | //gfx_putchar( 'O' ); |
---|
525 | gfx_goto( x + 2, y + 2 ); |
---|
526 | gfx_putchar( 'O' ); |
---|
527 | gfx_goto( x, y + 2 ); |
---|
528 | gfx_putchar( 'o' ); |
---|
529 | gfx_goto( x + 1, y + 3 ); |
---|
530 | gfx_putchar( 'o' ); |
---|
531 | gfx_color( GRAY ); |
---|
532 | gfx_goto( x, y + 4 ); |
---|
533 | gfx_putchar( '°' ); |
---|
534 | gfx_goto( x + 2, y + 4 ); |
---|
535 | gfx_putchar( '.' ); |
---|
536 | gfx_goto( x + 1, y + 5 ); |
---|
537 | gfx_putchar( '.' ); |
---|
538 | break; |
---|
539 | case 3: |
---|
540 | gfx_color( CYAN ); |
---|
541 | //gfx_goto( x + 2, y + 1 ); |
---|
542 | //gfx_putchar( 'O' ); |
---|
543 | gfx_goto( x + 1, y + 2 ); |
---|
544 | gfx_putchar( 'O' ); |
---|
545 | gfx_goto( x - 1, y + 2 ); |
---|
546 | gfx_putchar( 'o' ); |
---|
547 | gfx_goto( x + 2, y + 3 ); |
---|
548 | gfx_putchar( 'o' ); |
---|
549 | gfx_color( GRAY ); |
---|
550 | gfx_goto( x, y + 3 ); |
---|
551 | gfx_putchar( '°' ); |
---|
552 | gfx_goto( x + 1, y + 4 ); |
---|
553 | gfx_putchar( '°' ); |
---|
554 | gfx_goto( x, y + 5 ); |
---|
555 | gfx_putchar( '.' ); |
---|
556 | break; |
---|
557 | } |
---|
558 | } |
---|
559 | |
---|
560 | static void draw_beam( int x, int y, int frame ) |
---|
561 | { |
---|
562 | int r = (29 - frame) * (29 - frame) / 8; |
---|
563 | int i; |
---|
564 | |
---|
565 | switch( frame ) |
---|
566 | { |
---|
567 | case 24: |
---|
568 | gfx_color( WHITE ); |
---|
569 | gfx_goto( x, y-3 ); |
---|
570 | gfx_putstr( "__" ); |
---|
571 | gfx_goto( x-1, y-2 ); |
---|
572 | gfx_putchar( '\'' ); |
---|
573 | gfx_goto( x+2, y-2 ); |
---|
574 | gfx_putchar( '`' ); |
---|
575 | break; |
---|
576 | case 23: |
---|
577 | gfx_color( CYAN ); |
---|
578 | gfx_goto( x, y-3 ); |
---|
579 | gfx_putstr( "__" ); |
---|
580 | gfx_color( WHITE ); |
---|
581 | gfx_goto( x-2, y-2 ); |
---|
582 | gfx_putstr( "-'" ); |
---|
583 | gfx_goto( x+2, y-2 ); |
---|
584 | gfx_putstr( "`-" ); |
---|
585 | break; |
---|
586 | case 22: |
---|
587 | gfx_color( CYAN ); |
---|
588 | gfx_goto( x, y-3 ); |
---|
589 | gfx_putstr( "__" ); |
---|
590 | gfx_goto( x-1, y-2 ); |
---|
591 | gfx_putchar( '\'' ); |
---|
592 | gfx_goto( x+2, y-2 ); |
---|
593 | gfx_putchar( '`' ); |
---|
594 | gfx_color( WHITE ); |
---|
595 | gfx_goto( x-3, y-2 ); |
---|
596 | gfx_putstr( ",-" ); |
---|
597 | gfx_goto( x+3, y-2 ); |
---|
598 | gfx_putstr( "-." ); |
---|
599 | break; |
---|
600 | case 21: |
---|
601 | gfx_color( CYAN ); |
---|
602 | gfx_goto( x-1, y-3 ); |
---|
603 | gfx_putstr( "____" ); |
---|
604 | gfx_goto( x-2, y-2 ); |
---|
605 | gfx_putchar( '\'' ); |
---|
606 | gfx_goto( x+3, y-2 ); |
---|
607 | gfx_putchar( '`' ); |
---|
608 | gfx_color( WHITE ); |
---|
609 | gfx_goto( x-4, y-2 ); |
---|
610 | gfx_putstr( ",-" ); |
---|
611 | gfx_goto( x+4, y-2 ); |
---|
612 | gfx_putstr( "-." ); |
---|
613 | break; |
---|
614 | case 20: |
---|
615 | gfx_color( WHITE ); |
---|
616 | gfx_goto( x, y-3 ); |
---|
617 | gfx_putstr( "%%" ); |
---|
618 | gfx_goto( x-4, y-2 ); |
---|
619 | gfx_putchar( ',' ); |
---|
620 | gfx_goto( x+5, y-2 ); |
---|
621 | gfx_putchar( '.' ); |
---|
622 | gfx_color( CYAN ); |
---|
623 | gfx_goto( x-1, y-3 ); |
---|
624 | gfx_putchar( ':' ); |
---|
625 | gfx_goto( x+2, y-3 ); |
---|
626 | gfx_putchar( ':' ); |
---|
627 | gfx_goto( x-3, y-2 ); |
---|
628 | gfx_putstr( "-'" ); |
---|
629 | gfx_goto( x+3, y-2 ); |
---|
630 | gfx_putstr( "`-" ); |
---|
631 | break; |
---|
632 | case 19: |
---|
633 | gfx_color( WHITE ); |
---|
634 | gfx_goto( x, y-4 ); |
---|
635 | gfx_putstr( "%%" ); |
---|
636 | gfx_goto( x, y-3 ); |
---|
637 | gfx_putstr( "##" ); |
---|
638 | gfx_color( CYAN ); |
---|
639 | gfx_goto( x-1, y-4 ); |
---|
640 | gfx_putchar( ':' ); |
---|
641 | gfx_goto( x+2, y-4 ); |
---|
642 | gfx_putchar( ':' ); |
---|
643 | gfx_goto( x-1, y-3 ); |
---|
644 | gfx_putchar( '%' ); |
---|
645 | gfx_goto( x+2, y-3 ); |
---|
646 | gfx_putchar( '%' ); |
---|
647 | gfx_goto( x-4, y-2 ); |
---|
648 | gfx_putstr( ",-'" ); |
---|
649 | gfx_goto( x+3, y-2 ); |
---|
650 | gfx_putstr( "`-." ); |
---|
651 | gfx_color( BLUE ); |
---|
652 | gfx_goto( x-2, y-3 ); |
---|
653 | gfx_putchar( ':' ); |
---|
654 | gfx_goto( x+3, y-3 ); |
---|
655 | gfx_putchar( ':' ); |
---|
656 | break; |
---|
657 | case 18: |
---|
658 | default: |
---|
659 | r = (18 - frame) * (18 - frame); |
---|
660 | gfx_color( WHITE ); |
---|
661 | gfx_goto( x-1, y-5-r ); |
---|
662 | gfx_putstr( ":%%:" ); |
---|
663 | gfx_goto( x-1, y-4-r ); |
---|
664 | gfx_putstr( "%##%" ); |
---|
665 | gfx_color( CYAN ); |
---|
666 | gfx_goto( x-2, y-4-r ); |
---|
667 | gfx_putchar( ':' ); |
---|
668 | gfx_goto( x+3, y-4-r ); |
---|
669 | gfx_putchar( ':' ); |
---|
670 | gfx_goto( x-2, y-2 ); |
---|
671 | gfx_putchar( '\'' ); |
---|
672 | gfx_goto( x+3, y-2 ); |
---|
673 | gfx_putchar( '`' ); |
---|
674 | gfx_color( BLUE ); |
---|
675 | gfx_goto( x-3, y-2 ); |
---|
676 | gfx_putchar( ':' ); |
---|
677 | gfx_goto( x+4, y-2 ); |
---|
678 | gfx_putchar( ':' ); |
---|
679 | for( i = 0; i <= r; i++ ) |
---|
680 | { |
---|
681 | gfx_color( WHITE ); |
---|
682 | gfx_goto( x-1, y-3-i ); |
---|
683 | gfx_putstr( (i+frame) % 5 ? "####" : "%%%%" ); |
---|
684 | gfx_color( CYAN ); |
---|
685 | gfx_goto( x-2, y-3-i ); |
---|
686 | gfx_putchar( '%' ); |
---|
687 | gfx_goto( x+3, y-3-i ); |
---|
688 | gfx_putchar( '%' ); |
---|
689 | gfx_color( BLUE ); |
---|
690 | gfx_goto( x-3, y-3-i ); |
---|
691 | gfx_putchar( ':' ); |
---|
692 | gfx_goto( x+4, y-3-i ); |
---|
693 | gfx_putchar( ':' ); |
---|
694 | } |
---|
695 | break; |
---|
696 | } |
---|
697 | } |
---|
698 | |
---|
699 | static void draw_nuke( int x, int y, int frame ) |
---|
700 | { |
---|
701 | int r = (29 - frame) * (29 - frame) / 8; |
---|
702 | |
---|
703 | /* Lots of duplicate pixels, but we don't care */ |
---|
704 | gfx_color( BLUE ); |
---|
705 | draw_circle( x, y, r++, ':' ); |
---|
706 | gfx_color( CYAN ); |
---|
707 | draw_circle( x, y, r++, '%' ); |
---|
708 | gfx_color( WHITE ); |
---|
709 | draw_circle( x, y, r++, '#' ); |
---|
710 | draw_circle( x, y, r++, '#' ); |
---|
711 | } |
---|
712 | |
---|
713 | static void draw_circle( int x, int y, int r, char c ) |
---|
714 | { |
---|
715 | int test, dx, dy; |
---|
716 | |
---|
717 | /* Optimized Bresenham. Kick ass. */ |
---|
718 | for( test = 0, dx = 0, dy = r ; dx <= dy ; dx++ ) |
---|
719 | { |
---|
720 | gfx_putcharTO( x + dx, y + dy / 2, c ); |
---|
721 | gfx_putcharTO( x - dx, y + dy / 2, c ); |
---|
722 | gfx_putcharTO( x + dx, y - dy / 2, c ); |
---|
723 | gfx_putcharTO( x - dx, y - dy / 2, c ); |
---|
724 | |
---|
725 | gfx_putcharTO( x + dy, y + dx / 2, c ); |
---|
726 | gfx_putcharTO( x - dy, y + dx / 2, c ); |
---|
727 | gfx_putcharTO( x + dy, y - dx / 2, c ); |
---|
728 | gfx_putcharTO( x - dy, y - dx / 2, c ); |
---|
729 | |
---|
730 | test += test > 0 ? dx - dy-- : dx; |
---|
731 | } |
---|
732 | } |
---|
733 | |
---|