Ignore:
Timestamp:
12/13/02 20:27:16 (10 years ago)
Author:
sam
Message:
  • moved nuke from explosions to weapons.
  • used a cool Bresenham algorithm to draw the nuke circles.
  • nuke collides with aliens.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ttyvaders/trunk/explosions.c

    r12 r16  
    11 
    22#include <stdlib.h> 
    3 #include <math.h> 
    43 
    54#include "common.h" 
     
    76static void draw_small_explosion( int x, int y, int frame ); 
    87static void draw_big_explosion( int x, int y, int frame ); 
    9 static void draw_huge_explosion( int x, int y, int frame ); 
    108 
    119void init_explosions( game *g, explosions *ex ) 
     
    8684        switch( ex->type[i] ) 
    8785        { 
    88             case 2: 
    89                 draw_huge_explosion( ex->x[i], ex->y[i], ex->n[i] ); 
    90                 break; 
    9186            case 1: 
    9287                draw_big_explosion( ex->x[i], ex->y[i], ex->n[i] ); 
     
    309304} 
    310305 
    311 static void draw_circle( int x, int y, float r ); 
    312  
    313 static void draw_huge_explosion( int x, int y, int frame ) 
    314 { 
    315     float r = 1.5 * (30 - frame); 
    316  
    317     GFX_COLOR( BLUE ); 
    318     draw_circle( x, y, r ); 
    319  
    320     r += 0.7; 
    321  
    322     GFX_COLOR( CYAN ); 
    323     draw_circle( x, y, r ); 
    324  
    325     r += 0.7; 
    326  
    327     GFX_COLOR( WHITE ); 
    328     draw_circle( x, y, r ); 
    329 } 
    330  
    331 static void draw_circle( int x, int y, float r ) 
    332 { 
    333 #if 1 
    334     float c; 
    335  
    336     for( c = 0 ; c <= 90 ; c += 1 ) 
    337     { 
    338         float dx = 0.5 + r * 2.0 * sin( c * M_PI / 180.0 ); 
    339         float dy = 0.5 + r * cos( c * M_PI / 180.0 ); 
    340  
    341         GFX_GOTO( x + dx, y + dy ); 
    342         GFX_WRITE( '#' ); 
    343         GFX_GOTO( x - dx, y + dy ); 
    344         GFX_WRITE( '#' ); 
    345         GFX_GOTO( x + dx, y - dy ); 
    346         GFX_WRITE( '#' ); 
    347         GFX_GOTO( x - dx, y - dy ); 
    348         GFX_WRITE( '#' ); 
    349     } 
    350 #endif 
    351  
    352 #if 0 
    353 int dx,dy,a2,b2, S, T; 
    354 float a = r*8, b = r*2; 
    355  
    356  a2 = a*a; 
    357  b2 = b*b; 
    358  dx = 0; 
    359  dy = b; 
    360  S = a2*(1-2*b) + 2*b2; 
    361  T = b2 - 2*a2*(2*b-1); 
    362         GFX_GOTO( x + dx, y + dy ); 
    363         GFX_WRITE( '#' ); 
    364         GFX_GOTO( x - dx, y + dy ); 
    365         GFX_WRITE( '#' ); 
    366         GFX_GOTO( x + dx, y - dy ); 
    367         GFX_WRITE( '#' ); 
    368         GFX_GOTO( x - dx, y - dy ); 
    369         GFX_WRITE( '#' ); 
    370  
    371  do 
    372    { 
    373     if (S<0) 
    374        { 
    375         S += 2*b2*(2*x+3); 
    376         T += 4*b2*(x+1); 
    377         dx++; 
    378        } 
    379       else if (T<0) 
    380           { 
    381            S += 2*b2*(2*x+3) - 4*a2*(dy-1); 
    382            T += 4*b2*(x+1) - 2*a2*(2*dy-3); 
    383            dx++; 
    384            dy--; 
    385           } 
    386          else 
    387           { 
    388            S -= 4*a2*(dy-1); 
    389            T -= 2*a2*(2*dy-3); 
    390            dy--; 
    391           } 
    392         GFX_GOTO( x + dx, y + dy ); 
    393         GFX_WRITE( '#' ); 
    394         GFX_GOTO( x - dx, y + dy ); 
    395         GFX_WRITE( '#' ); 
    396         GFX_GOTO( x + dx, y - dy ); 
    397         GFX_WRITE( '#' ); 
    398         GFX_GOTO( x - dx, y - dy ); 
    399         GFX_WRITE( '#' ); 
    400    } 
    401  while (dy>0); 
    402 #endif 
    403  
    404 } 
    405  
Note: See TracChangeset for help on using the changeset viewer.