Changeset 24


Ignore:
Timestamp:
Dec 15, 2002, 6:16:45 PM (20 years ago)
Author:
Sam Hocevar
Message:
  • new weapon: bomb.
  • beam now collides with aliens.
Location:
ttyvaders/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • ttyvaders/trunk/doc/shapes.txt

    r22 r24  
    2626 _o|o_
    2727  T|T
     28
     29                 _
     30    ,(|).       / \
     31   /,-'-.\    ,(_X_).
    2832
    2933Bonus
     
    6266  |    \   /     |
    6367
     68       ___     _,  ._     ,^.     _,  ._
     69  . o |___>   / |  | \    | |  ,-' /  \ `-.
     70             / /    \ \   |_|  \,-'    `-./
     71             `'      `'
     72       ___   ,.      ,.    _
     73      <___|  \ \    / /   | |  /`-.    ,-'\
     74              \_|  |_/    | |  `-._\  /_,-'
     75                          `v'      `  '
     76
     77  |       |  |    ||||    |/\|
     78 ||      ||  ||  ||||||  ||/\||
     79 |       |    |  |    |  |    |
    6480
    6581                                                                :%%:
     
    6783  __     __       __        ____        :%%:       :%##%:     :%####%:
    6884 '  `  -'  `-  ,-'  `-.  ,-'    `-.  ,-'    `-.  ,-'    `-.  ,-'    `-.
     85
     86       ,--.
     87      (    )
     88       `--'
     89       o O
     90        o °
     91       . °
     92        .
     93
     94       ,--.
     95      (    )
     96       ||||
     97       ||||
     98        ||   
     99         |   
     100         
    69101
    70102Explosions
  • ttyvaders/trunk/src/aliens.c

    r20 r24  
    8282            {
    8383                case ALIEN_POOLP:
    84                     al->life[i] = 2;
     84                    al->life[i] = 3;
    8585                    break;
    8686                case ALIEN_BOOL:
    87                     al->life[i] = 2;
     87                    al->life[i] = 3;
    8888                    break;
    8989                case ALIEN_BRAH:
    90                     al->life[i] = 2;
     90                    al->life[i] = 3;
    9191                    break;
    9292                case ALIEN_NONE:
  • ttyvaders/trunk/src/collide.c

    r20 r24  
    1818                break;
    1919            case WEAPON_SEEKER:
     20            case WEAPON_BOMB:
    2021                if( x <= t->left[y]
    2122                     || x >= t->right[y] )
     23                {
     24                    int damage = wp->type[i] == WEAPON_SEEKER ? 1 : 2;
     25
     26                    add_explosion( g, ex, x, y, 0, 1, wp->type[i] == WEAPON_SEEKER ? EXPLOSION_SMALL : EXPLOSION_MEDIUM );
     27
     28                    if( x <= t->left[y] )
     29                    {
     30                        t->right[y-2] -= damage - 1;
     31                        t->left[y-1] -= damage;
     32                        t->left[y] -= damage + 1;
     33                        t->left[y+1] -= damage;
     34                        t->right[y+2] -= damage - 1;
     35                    }
     36                    else
     37                    {
     38                        t->right[y-2] += damage - 1;
     39                        t->right[y-1] += damage;
     40                        t->right[y] += damage + 1;
     41                        t->right[y+1] += damage;
     42                        t->right[y+2] += damage - 1;
     43                    }
     44
     45                    wp->type[i] = WEAPON_NONE;
     46                }
     47                break;
     48            case WEAPON_LASER:
     49                if( x <= t->left[y+1]
     50                     || x >= t->right[y+1] )
     51                {
     52                    add_explosion( g, ex, x, y+1, 0, 1, EXPLOSION_SMALL );
     53
     54                    if( x <= t->left[y+1] )
     55                    {
     56                        t->left[y]--;
     57                        t->left[y+1]-=2;
     58                        t->left[y+2]--;
     59                    }
     60                    else
     61                    {
     62                        t->right[y]++;
     63                        t->right[y+1]+=2;
     64                        t->right[y+2]++;
     65                    }
     66
     67                    wp->type[i] = WEAPON_NONE;
     68                }
     69                else if( x <= t->left[y]
     70                          || x >= t->right[y] )
    2271                {
    2372                    add_explosion( g, ex, x, y, 0, 1, EXPLOSION_SMALL );
     
    3988                }
    4089                break;
    41             case WEAPON_LASER:
    42                 if( x <= t->left[y+1]
    43                      || x >= t->right[y+1] )
    44                 {
    45                     add_explosion( g, ex, x, y+1, 0, 1, EXPLOSION_SMALL );
    46 
    47                     if( x <= t->left[y+1] )
    48                     {
    49                         t->left[y]--;
    50                         t->left[y+1]-=2;
    51                         t->left[y+2]--;
    52                     }
    53                     else
    54                     {
    55                         t->right[y]++;
    56                         t->right[y+1]+=2;
    57                         t->right[y+2]++;
    58                     }
    59 
    60                     wp->type[i] = WEAPON_NONE;
    61                 }
    62                 else if( x <= t->left[y]
    63                           || x >= t->right[y] )
    64                 {
    65                     add_explosion( g, ex, x, y, 0, 1, EXPLOSION_SMALL );
    66 
    67                     if( x <= t->left[y] )
    68                     {
    69                         t->left[y-1]--;
    70                         t->left[y]-=2;
    71                         t->left[y+1]--;
    72                     }
    73                     else
    74                     {
    75                         t->right[y-1]++;
    76                         t->right[y]+=2;
    77                         t->right[y+1]++;
    78                     }
    79 
    80                     wp->type[i] = WEAPON_NONE;
    81                 }
    82                 break;
    8390            case WEAPON_NUKE:
    84                 /* The nuke does not break the tunnel */
     91            case WEAPON_BEAM:
     92                /* The nuke and the laser do not break the tunnel */
    8593                break;
    8694        }
     
    127135                }
    128136                break;
     137            case WEAPON_BEAM:
     138                r = (29 - wp->n[i]) * (29 - wp->n[i]) / 8;
     139
     140                for( j = 0; j < ALIENS; j++ )
     141                {
     142                    if( al->type[j] == ALIEN_NONE )
     143                    {
     144                        continue;
     145                    }
     146
     147                    if( x >= al->x[j] && x <= al->x[j] + 4
     148                         && y >= al->y[j] + 2 && y-5-r <= al->y[j] )
     149                    {
     150                        al->life[j] -= 4;
     151                        if( al->life[j] <= 0 )
     152                        {
     153                            al->type[j] = ALIEN_NONE;
     154                            add_explosion( g, ex, al->x[j], al->y[j], 0, 0, EXPLOSION_MEDIUM );
     155                            add_bonus( g, g->bo, al->x[j], al->y[j], GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE );
     156                        }
     157                    }
     158                }
     159                break;
     160
    129161            case WEAPON_LASER:
    130162                for( j = 0; j < ALIENS; j++ )
     
    142174                        {
    143175                            al->type[j] = ALIEN_NONE;
    144                             add_explosion( g, ex, x, y, 0, 0, EXPLOSION_MEDIUM );
    145                             add_bonus( g, g->bo, x, y, GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE );
     176                            add_explosion( g, ex, al->x[j], al->y[j], 0, 0, EXPLOSION_MEDIUM );
     177                            add_bonus( g, g->bo, al->x[j], al->y[j], GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE );
    146178                        }
    147179                        ok = 1;
     
    154186                        {
    155187                            al->type[j] = ALIEN_NONE;
    156                             add_explosion( g, ex, x, y+1, 0, 0, EXPLOSION_MEDIUM );
    157                             add_bonus( g, g->bo, x, y+1, GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE );
     188                            add_explosion( g, ex, al->x[j], al->y[j]+1, 0, 0, EXPLOSION_MEDIUM );
     189                            add_bonus( g, g->bo, al->x[j], al->y[j]+1, GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE );
    158190                        }
    159191                        ok = 1;
     
    163195                if( ok )
    164196                {
     197                    add_explosion( g, ex, x, y+1, 0, 0, EXPLOSION_SMALL );
    165198                    wp->type[i] = WEAPON_NONE;
    166199                }
     
    168201
    169202            case WEAPON_SEEKER:
     203            case WEAPON_BOMB:
    170204                for( j = 0; j < ALIENS; j++ )
    171205                {
     
    182216                        {
    183217                            al->type[j] = ALIEN_NONE;
    184                             add_explosion( g, ex, x, y, 0, 0, EXPLOSION_MEDIUM );
    185                             add_bonus( g, g->bo, x, y, GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE );
     218                            add_explosion( g, ex, al->x[j], al->y[j], 0, 0, EXPLOSION_MEDIUM );
     219                            add_bonus( g, g->bo, al->x[j], al->y[j], GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE );
    186220                        }
    187221                        ok = 1;
     
    191225                if( ok )
    192226                {
     227                    add_explosion( g, ex, x, y+1, 0, 0, wp->type[i] == WEAPON_SEEKER ? EXPLOSION_SMALL : EXPLOSION_MEDIUM );
    193228                    wp->type[i] = WEAPON_NONE;
    194229                }
  • ttyvaders/trunk/src/common.h

    r22 r24  
    11
    22#define STARS 50
    3 #define WEAPONS 50
     3#define WEAPONS 100
    44#define BONUS 30
    55#define ALIENS 30
    6 #define EXPLOSIONS 20
     6#define EXPLOSIONS 100
    77
    88#ifdef USE_SLANG
     
    5353typedef struct
    5454{
    55     enum { WEAPON_NONE, WEAPON_LASER, WEAPON_SEEKER, WEAPON_NUKE, WEAPON_BEAM } type[WEAPONS];
     55    enum { WEAPON_NONE, WEAPON_LASER, WEAPON_SEEKER, WEAPON_NUKE, WEAPON_BEAM, WEAPON_LIGHTNING, WEAPON_BOMB } type[WEAPONS];
    5656    int x[WEAPONS];
    5757    int y[WEAPONS];
  • ttyvaders/trunk/src/main.c

    r22 r24  
    128128                    {
    129129                        g->p->weapon = 4;
    130                         add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, -24, -16, WEAPON_SEEKER );
    131                         add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 24, -16, WEAPON_SEEKER );
     130                        add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, -16, WEAPON_BOMB );
    132131                    }
    133132                case ' ':
     
    137136                        add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, 0, -16, WEAPON_LASER );
    138137                        add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 0, -16, WEAPON_LASER );
     138                        /* Extra shtuph */
     139                        add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, -24, -16, WEAPON_SEEKER );
     140                        add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 24, -16, WEAPON_SEEKER );
     141                        /* More shtuph */
     142                        add_weapon( g, g->wp, (g->p->x + 1) << 4, (g->p->y - 1) << 4, 0, -16, WEAPON_LASER );
     143                        add_weapon( g, g->wp, (g->p->x + 4) << 4, (g->p->y - 1) << 4, 0, -16, WEAPON_LASER );
     144                        /* Even more shtuph */
     145                        add_weapon( g, g->wp, (g->p->x + 2) << 4, (g->p->y - 1) << 4, 0, -16, WEAPON_LASER );
     146                        add_weapon( g, g->wp, (g->p->x + 3) << 4, (g->p->y - 1) << 4, 0, -16, WEAPON_LASER );
     147                        /* Extra shtuph */
     148                        add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, -32, 0, WEAPON_SEEKER );
     149                        add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 32, 0, WEAPON_SEEKER );
    139150                    }
    140151                    break;
     
    144155        usleep(40000);
    145156
    146         if( GET_RAND(0,10) == 0 )
     157        if( !poz || skip )
    147158        {
    148             int list[3] = { ALIEN_POOLP, ALIEN_BOOL, ALIEN_BRAH };
    149 
    150             add_alien( g, g->al, 0, rand() % g->h / 2, list[GET_RAND(0,3)] );
     159            skip = 0;
     160
     161            /* XXX: to be removed */
     162            if( GET_RAND(0,10) == 0 )
     163            {
     164                int list[3] = { ALIEN_POOLP, ALIEN_BOOL, ALIEN_BRAH };
     165
     166                add_alien( g, g->al, 0, rand() % g->h / 2, list[GET_RAND(0,3)] );
     167            }
     168
     169            /* Update game rules */
     170            if( g->t->right[1] - g->t->left[1] == g->t->w )
     171            {
     172                g->t->w = 85 - g->t->w;
     173            }
     174
     175            /* Scroll and update positions */
     176            collide_player_tunnel( g, g->p, g->t, g->ex );
     177            update_player( g, g->p );
     178            collide_player_tunnel( g, g->p, g->t, g->ex );
     179
     180            update_starfield( g, g->sf );
     181            update_bonus( g, g->bo );
     182            update_aliens( g, g->al );
     183
     184            collide_weapons_tunnel( g, g->wp, g->t, g->ex );
     185            collide_weapons_aliens( g, g->wp, g->al, g->ex );
     186            update_weapons( g, g->wp );
     187            collide_weapons_tunnel( g, g->wp, g->t, g->ex );
     188            collide_weapons_aliens( g, g->wp, g->al, g->ex );
     189
     190            update_explosions( g, g->ex );
     191            /*if(purcompteur%2)*/ update_tunnel( g, g->t );
    151192        }
    152 
    153         if( poz )
    154         {
    155             if( skip )
    156             {
    157                 skip = 0;
    158             }
    159             else
    160             {
    161                 continue;
    162             }
    163         }
    164 
    165         /* Update game rules */
    166         if( g->t->right[1] - g->t->left[1] == g->t->w )
    167         {
    168             g->t->w = 85 - g->t->w;
    169         }
    170 
    171         /* Scroll and update positions */
    172         collide_player_tunnel( g, g->p, g->t, g->ex );
    173         update_player( g, g->p );
    174         collide_player_tunnel( g, g->p, g->t, g->ex );
    175 
    176         update_starfield( g, g->sf );
    177         update_bonus( g, g->bo );
    178         update_aliens( g, g->al );
    179 
    180         collide_weapons_tunnel( g, g->wp, g->t, g->ex );
    181         collide_weapons_aliens( g, g->wp, g->al, g->ex );
    182         update_weapons( g, g->wp );
    183         collide_weapons_tunnel( g, g->wp, g->t, g->ex );
    184         collide_weapons_aliens( g, g->wp, g->al, g->ex );
    185 
    186         update_explosions( g, g->ex );
    187         /*if(purcompteur%2)*/ update_tunnel( g, g->t );
    188193
    189194        /* Clear screen */
     
    196201        draw_aliens( g, g->al );
    197202        draw_player( g, g->p );
     203        draw_explosions( g, g->ex );
    198204        draw_weapons( g, g->wp );
    199         draw_explosions( g, g->ex );
    200205
    201206        /* Refresh */
  • ttyvaders/trunk/src/weapons.c

    r22 r24  
    55#include "common.h"
    66
     7static void draw_bomb( int x, int y, int vx, int vy );
    78static void draw_nuke( int x, int y, int frame );
    89static void draw_beam( int x, int y, int frame );
     
    4546                gfx_putchar( '@' );
    4647                break;
     48            case WEAPON_BOMB:
     49                gfx_color( GRAY );
     50                gfx_goto( (wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4 );
     51                gfx_putchar( '.' );
     52                gfx_goto( (wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4 );
     53                gfx_putchar( '.' );
     54                gfx_goto( (wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4 );
     55                gfx_putchar( '.' );
     56                gfx_goto( wp->x3[i] >> 4, wp->y3[i] >> 4 );
     57                gfx_putchar( '.' );
     58                gfx_goto( wp->x2[i] >> 4, wp->y2[i] >> 4 );
     59                gfx_putchar( '.' );
     60                draw_bomb( wp->x[i] >> 4, wp->y[i] >> 4, wp->vx[i], wp->vy[i] );
     61                break;
    4762            case WEAPON_BEAM:
    4863                draw_beam( wp->x[i] >> 4, wp->y[i] >> 4, wp->n[i] );
     
    7388                }
    7489                break;
     90            case WEAPON_BOMB:
    7591            case WEAPON_SEEKER:
    7692                /* Update tail */
     
    176192                    break;
    177193                case WEAPON_SEEKER:
     194                case WEAPON_BOMB:
    178195                    wp->x2[i] = x;
    179196                    wp->y2[i] = y;
     
    192209            }
    193210            break;
     211        }
     212    }
     213}
     214
     215static void draw_bomb( int x, int y, int vx, int vy )
     216{
     217    vy *= 2;
     218    gfx_color( CYAN );
     219
     220    if( vx > vy )
     221    {
     222        if( vx > -vy ) /* right quarter */
     223        {
     224            if( vy > vx/4 )
     225            {
     226                /* -1pi/6 */
     227                gfx_goto( x-4, y-1 );
     228                gfx_putstr( "/`-." );
     229                gfx_goto( x-4, y );
     230                gfx_putstr( "`-._\\" );
     231                gfx_goto( x, y+1 );
     232                gfx_putchar( '`' );
     233            }
     234            else if( vy < -vx/4 )
     235            {
     236                /* 1pi/6 */
     237                gfx_goto( x-1, y-1 );
     238                gfx_putstr( "_," );
     239                gfx_goto( x-4, y );
     240                gfx_putstr( ",-' /" );
     241                gfx_goto( x-4, y+1 );
     242                gfx_putstr( "\\,-'" );
     243            }
     244            else
     245            {
     246                /* 0pi/6 */
     247                gfx_goto( x-4, y-1 );
     248                gfx_putstr( "____" );
     249                gfx_goto( x-5, y );
     250                gfx_putstr( "|____>" );
     251            }
     252        }
     253        else /* top quarter */
     254        {
     255            if( vx > -vy/4 )
     256            {
     257                /* 2pi/6 */
     258                gfx_goto( x-1, y-1 );
     259                gfx_putstr( "_," );
     260                gfx_goto( x-2, y );
     261                gfx_putstr( "/ |" );
     262                gfx_goto( x-3, y+1 );
     263                gfx_putstr( "/ /" );
     264                gfx_goto( x-3, y+2 );
     265                gfx_putstr( "`'" );
     266            }
     267            else if( vx < vy/4 )
     268            {
     269                /* 4pi/6 */
     270                gfx_goto( x, y-1 );
     271                gfx_putstr( "._" );
     272                gfx_goto( x, y );
     273                gfx_putstr( "| \\" );
     274                gfx_goto( x+1, y+1 );
     275                gfx_putstr( "\\ \\" );
     276                gfx_goto( x+2, y+2 );
     277                gfx_putstr( "`'" );
     278            }
     279            else
     280            {
     281                /* 3pi/6 */
     282                gfx_goto( x-1, y );
     283                gfx_putstr( ",^." );
     284                gfx_goto( x-1, y+1 );
     285                gfx_putstr( "| |" );
     286                gfx_goto( x-1, y+2 );
     287                gfx_putstr( "|_|" );
     288            }
     289        }
     290    }
     291    else
     292    {
     293        if( vx > -vy ) /* bottom quarter */
     294        {
     295            if( vx > vy/4 )
     296            {
     297                /* -2pi/6 */
     298                gfx_goto( x-2, y-2 );
     299                gfx_putstr( ",." );
     300                gfx_goto( x-2, y-1 );
     301                gfx_putstr( "\\ \\" );
     302                gfx_goto( x-1, y );
     303                gfx_putstr( "\\_|" );
     304            }
     305            else if( vx < -vy/4 )
     306            {
     307                /* -4pi/6 */
     308                gfx_goto( x+1, y-2 );
     309                gfx_putstr( ",." );
     310                gfx_goto( x, y-1 );
     311                gfx_putstr( "/ /" );
     312                gfx_goto( x-1, y );
     313                gfx_putstr( "|_/" );
     314            }
     315            else
     316            {
     317                /* -3pi/6 */
     318                gfx_goto( x, y-3 );
     319                gfx_putchar( '_' );
     320                gfx_goto( x-1, y-2 );
     321                gfx_putstr( "| |" );
     322                gfx_goto( x-1, y-1 );
     323                gfx_putstr( "| |" );
     324                gfx_goto( x-1, y );
     325                gfx_putstr( "`v'" );
     326            }
     327        }
     328        else /* left quarter */
     329        {
     330            if( vy > -vx/4 )
     331            {
     332                /* -5pi/6 */
     333                gfx_goto( x+1, y-1 );
     334                gfx_putstr( ",-'\\" );
     335                gfx_goto( x, y );
     336                gfx_putstr( "/_,-'" );
     337                gfx_goto( x, y+1 );
     338                gfx_putchar( '\'' );
     339            }
     340            else if( vy < vx/4 )
     341            {
     342                /* 5pi/6 */
     343                gfx_goto( x, y-1 );
     344                gfx_putstr( "._" );
     345                gfx_goto( x, y );
     346                gfx_putstr( "\\ `-." );
     347                gfx_goto( x+1, y+1 );
     348                gfx_putstr( "`-./" );
     349            }
     350            else
     351            {
     352                /* 6pi/6 */
     353                gfx_goto( x+1, y-1 );
     354                gfx_putstr( "____" );
     355                gfx_goto( x, y );
     356                gfx_putstr( "<____|" );
     357            }
    194358        }
    195359    }
Note: See TracChangeset for help on using the changeset viewer.