Changeset 62 for ttyvaders


Ignore:
Timestamp:
Dec 23, 2002, 4:06:13 PM (20 years ago)
Author:
Sam Hocevar
Message:
  • better handling of special weapon timeout.
  • the bomb is now part of the standard fire button effect.
  • overlay for life and special weapon jauges.
Location:
ttyvaders/trunk/src
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • ttyvaders/trunk/src/Makefile.am

    r52 r62  
    2323        bonus.c \
    2424        ceo.c \
     25        collide.c \
    2526        common.h \
    2627        explosions.c \
     28        graphics.c \
    2729        main.c \
    2830        math.c \
     31        overlay.c \
     32        player.c \
    2933        starfield.c \
     34        tunnel.c \
    3035        weapons.c \
    31         collide.c \
    32         graphics.c \
    33         player.c \
    34         tunnel.c \
    3536        $(NULL)
    3637
  • ttyvaders/trunk/src/common.h

    r60 r62  
    44 *                 All Rights Reserved
    55 *
    6  *   $Id: common.h,v 1.13 2002/12/23 13:46:27 sam Exp $
     6 *   $Id: common.h,v 1.14 2002/12/23 15:06:13 sam Exp $
    77 *
    88 *   This program is free software; you can redistribute it and/or modify
     
    2121 */
    2222
    23 #define MAX_LIFE 1000
    24 
     23/*
     24 * Compile-time limits
     25 */
    2526#define STARS 50
    2627#define WEAPONS 200
     
    2930#define EXPLOSIONS 200
    3031
     32/*
     33 * Game defines
     34 */
     35#define MAX_LIFE 1000
     36#define MAX_SPECIAL 200
     37
     38#define COST_NUKE     (100*MAX_SPECIAL/100)
     39#define COST_BEAM      (75*MAX_SPECIAL/100)
     40#define COST_FRAGBOMB  (50*MAX_SPECIAL/100)
     41
     42/*
     43 * Graphics primitives
     44 */
    3145#ifdef USE_SLANG
    3246#   include <slang.h>
     
    5064#define gfx_putcharTO(x,y,c) do{ gfx_goto(x,y); gfx_putchar(c); }while(0)
    5165
     66/*
     67 * Useful macros
     68 */
    5269#define GET_RAND(p,q) ((p)+(int)((1.0*((q)-(p)))*rand()/(RAND_MAX+1.0)))
    5370#define GET_MAX(a,b) ((a)>(b)?(a):(b))
    5471#define GET_MIN(a,b) ((a)<(b)?(a):(b))
    5572
     73/*
     74 * Game structures
     75 */
    5676typedef struct
    5777{
     
    106126    int x, y;
    107127    int vx, vy;
    108     int weapon, nuke;
     128    int weapon, special;
    109129    int life, dead;
    110130
     
    146166#define MAGENTA 10
    147167
    148 void collide_weapons_tunnel( game *g, weapons *wp, tunnel *t, explosions *ex );
    149 void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex );
    150 void collide_player_tunnel( game *g, player *p, tunnel *t, explosions *ex );
    151 
     168/*
     169 * From aliens.c
     170 */
    152171void init_aliens( game *g, aliens *al );
    153172void draw_aliens( game *g, aliens *al );
     
    155174void add_alien( game *g, aliens *al, int x, int y, int type );
    156175
     176/*
     177 * From bonus.c
     178 */
     179void init_bonus( game *g, bonus *bo );
     180void draw_bonus( game *g, bonus *bo );
     181void update_bonus( game *g, bonus *bo );
     182void add_bonus( game *g, bonus *bo, int x, int y, int type );
     183
     184/*
     185 * From ceo.c
     186 */
     187void ceo_alert( void );
     188
     189/*
     190 * From collide.c
     191 */
     192void collide_weapons_tunnel( game *g, weapons *wp, tunnel *t, explosions *ex );
     193void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex );
     194void collide_player_tunnel( game *g, player *p, tunnel *t, explosions *ex );
     195
     196/*
     197 * From explosions.c
     198 */
     199void init_explosions( game *g, explosions *ex );
     200void add_explosion( game *g, explosions *ex, int x, int y, int vx, int vy, int type );
     201void draw_explosions( game *g, explosions *ex );
     202void update_explosions( game *g, explosions *ex );
     203
     204/*
     205 * From graphics.c
     206 */
    157207int init_graphics( void );
    158208void init_game( game *g );
     
    162212void end_graphics( void );
    163213
     214/*
     215 * From math.c
     216 */
     217int r00t( int a );
     218
     219/*
     220 * From overlay.c
     221 */
     222void draw_overlay( game *g );
     223
     224/*
     225 * From player.c
     226 */
    164227player * create_player( game *g );
    165228void free_player( player *p );
     
    167230void update_player( game *g, player *p );
    168231
     232/*
     233 * From starfield.c
     234 */
     235starfield * create_starfield( game *g );
     236void draw_starfield( game *g, starfield *s );
     237void update_starfield( game *g, starfield *s );
     238void free_starfield( game *g, starfield *s );
     239
     240/*
     241 * From tunnel.c
     242 */
     243tunnel * create_tunnel( game *g, int w, int h );
     244void free_tunnel( tunnel *t );
     245void draw_tunnel( game *g, tunnel *t );
     246void update_tunnel( game *g, tunnel *t );
     247
     248/*
     249 * From weapons.c
     250 */
    169251void init_weapons( game *g, weapons *wp );
    170252void draw_weapons( game *g, weapons *wp );
     
    172254void add_weapon( game *g, weapons *wp, int x, int y, int vx, int vy, int type );
    173255
    174 void init_bonus( game *g, bonus *bo );
    175 void draw_bonus( game *g, bonus *bo );
    176 void update_bonus( game *g, bonus *bo );
    177 void add_bonus( game *g, bonus *bo, int x, int y, int type );
    178 
    179 starfield * create_starfield( game *g );
    180 void draw_starfield( game *g, starfield *s );
    181 void update_starfield( game *g, starfield *s );
    182 void free_starfield( game *g, starfield *s );
    183 
    184 tunnel * create_tunnel( game *g, int w, int h );
    185 void free_tunnel( tunnel *t );
    186 void draw_tunnel( game *g, tunnel *t );
    187 void update_tunnel( game *g, tunnel *t );
    188 
    189 void init_explosions( game *g, explosions *ex );
    190 void add_explosion( game *g, explosions *ex, int x, int y, int vx, int vy, int type );
    191 void draw_explosions( game *g, explosions *ex );
    192 void update_explosions( game *g, explosions *ex );
    193 
    194 void ceo_alert( void );
    195 
    196 int r00t( int a );
    197 
  • ttyvaders/trunk/src/main.c

    r60 r62  
    44 *                 All Rights Reserved
    55 *
    6  *   $Id: main.c,v 1.14 2002/12/23 13:46:27 sam Exp $
     6 *   $Id: main.c,v 1.15 2002/12/23 15:06:13 sam Exp $
    77 *
    88 *   This program is free software; you can redistribute it and/or modify
     
    8585            switch( key )
    8686            {
    87                 case 'q':
    88                     quit = 1;
    89                     break;
    90                 case 'p':
    91                     poz = !poz;
    92                     break;
    93                 case '\t':
    94                     ceo_alert();
    95                     poz = 1;
    96                     break;
    97                 case 's':
    98                     skip = 1;
    99                     break;
     87            case 'q':
     88                quit = 1;
     89                break;
     90            case 'p':
     91                poz = !poz;
     92                break;
     93            case '\t':
     94                ceo_alert();
     95                poz = 1;
     96                break;
     97            case 's':
     98                skip = 1;
     99                break;
     100            default:
     101                if( g->p->dead )
     102                {
     103                    break;
     104                }
     105
     106                switch( key )
     107                {
    100108                case 'h':
    101109                    g->p->vx = -2;
     
    111119                    break;
    112120                case 'n':
    113                     if( g->p->nuke == 0 )
    114                     {
    115                         g->p->nuke = 40;
     121                    if( g->p->special >= COST_NUKE )
     122                    {
     123                        g->p->special -= COST_NUKE;
    116124                        add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, 0, WEAPON_NUKE );
    117125                    }
    118126                    break;
    119                 case '\r':
    120                     if( g->p->nuke == 0 )
    121                     {
    122                         g->p->nuke = 40;
     127                case 'f':
     128                    if( g->p->special >= COST_FRAGBOMB )
     129                    {
     130                        g->p->special -= COST_FRAGBOMB;
     131                        add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, -16, WEAPON_FRAGBOMB );
     132                    }
     133                    break;
     134                case 'b':
     135                    if( g->p->special >= COST_BEAM )
     136                    {
     137                        g->p->special -= COST_BEAM;
    123138                        add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, 0, WEAPON_BEAM );
    124139                    }
    125140                    break;
    126                 case 'f':
    127                     if( g->p->nuke == 0 )
    128                     {
    129                         g->p->nuke = 40;
    130                         add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, -16, WEAPON_FRAGBOMB );
    131                     }
    132                     break;
    133                 case 'b':
    134                     if( g->p->weapon == 0 )
    135                     {
    136                         g->p->weapon = 4;
    137                         add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, -16, WEAPON_BOMB );
    138                     }
    139141                case ' ':
    140142                    if( g->p->weapon == 0 )
     
    143145                        add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, 0, -32, WEAPON_LASER );
    144146                        add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 0, -32, WEAPON_LASER );
    145                         /* Extra shtuph */
     147                        /* Extra schtuph */
    146148                        add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, -24, -16, WEAPON_SEEKER );
    147149                        add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 24, -16, WEAPON_SEEKER );
    148                         /* More shtuph */
     150                        /* More schtuph */
    149151                        add_weapon( g, g->wp, (g->p->x + 1) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER );
    150152                        add_weapon( g, g->wp, (g->p->x + 4) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER );
    151                         /* Even more shtuph */
     153                        /* Even more schtuph */
    152154                        add_weapon( g, g->wp, (g->p->x + 2) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER );
    153155                        add_weapon( g, g->wp, (g->p->x + 3) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER );
    154                         /* Extra shtuph */
     156                        /* Extra schtuph */
    155157                        add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, -32, 0, WEAPON_SEEKER );
    156158                        add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 32, 0, WEAPON_SEEKER );
    157                     }
    158                     break;
     159                        /* MORE SCHTUPH! */
     160                        add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, -16, WEAPON_BOMB );
     161                    }
     162                    break;
     163                }
    159164            }
    160165        }
     
    210215        draw_weapons( g, g->wp );
    211216        draw_player( g, g->p );
     217        draw_overlay( g );
    212218
    213219        /* Refresh */
  • ttyvaders/trunk/src/player.c

    r60 r62  
    44 *                 All Rights Reserved
    55 *
    6  *   $Id: player.c,v 1.6 2002/12/23 13:46:27 sam Exp $
     6 *   $Id: player.c,v 1.7 2002/12/23 15:06:13 sam Exp $
    77 *
    88 *   This program is free software; you can redistribute it and/or modify
     
    3535    p->vy = 0;
    3636    p->weapon = 0;
    37     p->nuke = 0;
     37    p->special = MAX_SPECIAL;
    3838    p->life = MAX_LIFE;
    3939
     
    8787    }
    8888
    89     if( p->nuke )
     89    if( p->special < MAX_SPECIAL )
    9090    {
    91         p->nuke--;
     91        p->special++;
    9292    }
    9393
Note: See TracChangeset for help on using the changeset viewer.