Changeset 64 for ttyvaders


Ignore:
Timestamp:
Dec 23, 2002, 5:21:38 PM (20 years ago)
Author:
Sam Hocevar
Message:
  • new timestamp for a new snapshot.
  • lots of sanity checks in collide.c.
  • moved usleep() to graphics.c.
  • added random key generator in the dummy driver.
  • cosmetic changes in the energy bars.
Location:
ttyvaders/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • ttyvaders/trunk/configure.ac

    r52 r64  
    11dnl Autoconf settings for ttyvaders
    22
    3 AC_INIT(ttyvaders,0.0cvs-20021218)
     3AC_INIT(ttyvaders,0.0cvs-20021223)
    44
    55AC_PREREQ(2.50)
     
    88AC_CANONICAL_SYSTEM
    99
    10 AM_INIT_AUTOMAKE(ttyvaders,0.0cvs-20021218)
     10AM_INIT_AUTOMAKE(ttyvaders,0.0cvs-20021223)
    1111AM_CONFIG_HEADER(config.h)
    1212
  • ttyvaders/trunk/src/collide.c

    r60 r64  
    44 *                 All Rights Reserved
    55 *
    6  *   $Id: collide.c,v 1.9 2002/12/23 13:46:27 sam Exp $
     6 *   $Id: collide.c,v 1.10 2002/12/23 16:21:38 sam Exp $
    77 *
    88 *   This program is free software; you can redistribute it and/or modify
     
    4242        case WEAPON_BOMB:
    4343        case WEAPON_FRAGBOMB:
     44            if( y < 0 || y >= g->h )
     45            {
     46                break;
     47            }
     48
    4449            if( x <= t->left[y]
    4550                 || x >= t->right[y] )
     
    5156                if( x <= t->left[y] )
    5257                {
    53                     t->right[y-2] -= damage - 1;
    54                     t->left[y-1] -= damage;
     58                    if( y-2 >= 0 ) t->right[y-2] -= damage - 1;
     59                    if( y-1 >= 0 ) t->left[y-1] -= damage;
    5560                    t->left[y] -= damage + 1;
    56                     t->left[y+1] -= damage;
    57                     t->right[y+2] -= damage - 1;
     61                    if( y+1 < g->h ) t->left[y+1] -= damage;
     62                    if( y+2 < g->h ) t->right[y+2] -= damage - 1;
    5863                }
    5964                else
    6065                {
    61                     t->right[y-2] += damage - 1;
    62                     t->right[y-1] += damage;
     66                    if( y-2 >= 0 ) t->right[y-2] += damage - 1;
     67                    if( y-1 >= 0 ) t->right[y-1] += damage;
    6368                    t->right[y] += damage + 1;
    64                     t->right[y+1] += damage;
    65                     t->right[y+2] += damage - 1;
     69                    if( y+1 < g->h ) t->right[y+1] += damage;
     70                    if( y+2 < g->h ) t->right[y+2] += damage - 1;
    6671                }
    6772
     
    8186                 j++ )
    8287            {
     88                if( y+j >= g->h || y+j < 0 )
     89                {
     90                    continue;
     91                }
     92
    8393                if( x <= t->left[y+j] || x >= t->right[y+j] )
    8494                {
     
    8898                    if( x <= t->left[y+j] )
    8999                    {
    90                         t->left[y+j-1]--;
     100                        if( y+j-1 >= 0 )
     101                        {
     102                            t->left[y+j-1]--;
     103                        }
    91104                        t->left[y+j] -= 2;
    92                         t->left[y+j+1]--;
     105                        if( y+j+1 < g->h )
     106                        {
     107                            t->left[y+j+1]--;
     108                        }
    93109                    }
    94110                    else
    95111                    {
    96                         t->right[y+j-1]++;
     112                        if( y+j-1 >= 0 )
     113                        {
     114                            t->right[y+j-1]++;
     115                        }
    97116                        t->right[y+j] += 2;
    98                         t->right[y+j+1]++;
     117                        if( y+j+1 < g->h )
     118                        {
     119                            t->right[y+j+1]++;
     120                        }
    99121                    }
    100122                    break;
     
    269291    if( p->x <= t->left[p->y] )
    270292    {
    271         p->x += 2;
    272         add_explosion( g, ex, p->x+1, p->y-2, 0, 0, EXPLOSION_SMALL );
    273         p->life -= 50;
     293        p->x += 3;
     294        p->vx = 2;
     295        add_explosion( g, ex, p->x+1, p->y-1, 0, 0, EXPLOSION_SMALL );
     296        p->life -= 80;
    274297    }
    275298    else if( p->x + 5 >= t->right[p->y] )
    276299    {
    277         p->x -= 2;
    278         add_explosion( g, ex, p->x+4, p->y-2, 0, 0, EXPLOSION_SMALL );
    279         p->life -= 50;
     300        p->x -= 3;
     301        p->vx = -2;
     302        add_explosion( g, ex, p->x+4, p->y-1, 0, 0, EXPLOSION_SMALL );
     303        p->life -= 80;
    280304    }
    281305}
  • ttyvaders/trunk/src/common.h

    r62 r64  
    44 *                 All Rights Reserved
    55 *
    6  *   $Id: common.h,v 1.14 2002/12/23 15:06:13 sam Exp $
     6 *   $Id: common.h,v 1.15 2002/12/23 16:21:38 sam Exp $
    77 *
    88 *   This program is free software; you can redistribute it and/or modify
     
    5656#   define gfx_putstr(x) addstr(x)
    5757#else
    58 #   define gfx_color(x) do{}while(0)
    59 #   define gfx_goto(x,y) do{}while(0)
    60 #   define gfx_putchar(x) do{}while(0)
    61 #   define gfx_putstr(x) do{}while(0)
     58#   define gfx_color(x) (void)(x)
     59#   define gfx_goto(x,y) do{ (void)(x); (void)(y); } while(0)
     60#   define gfx_putchar(x) (void)(x)
     61#   define gfx_putstr(x) (void)(x)
    6262#endif
    6363
     
    208208void init_game( game *g );
    209209char get_key( void );
     210void gfx_delay( void );
    210211void clear_graphics( void );
    211212void refresh_graphics( void );
  • ttyvaders/trunk/src/graphics.c

    r52 r64  
    44 *                 All Rights Reserved
    55 *
    6  *   $Id: graphics.c,v 1.5 2002/12/23 10:06:27 sam Exp $
     6 *   $Id: graphics.c,v 1.6 2002/12/23 16:21:38 sam Exp $
    77 *
    88 *   This program is free software; you can redistribute it and/or modify
     
    2121 */
    2222
     23#include "config.h"
     24
    2325#include <stdlib.h>
     26#include <unistd.h>
    2427
    2528#include "common.h"
     
    122125#else
    123126    /* Use dummy driver */
     127    char key = GET_RAND(0,256);
     128
     129    if( key != 'q' && key != 'p' && key != '\t' )
     130    {
     131        return key;
     132    }
    124133#endif
    125134
    126135    return 0;
     136}
     137
     138void gfx_delay( void )
     139{
     140#ifdef USE_SLANG
     141    usleep(40000);
     142#elif USE_NCURSES
     143    usleep(40000);
     144#else
     145    /* Use dummy driver */
     146#endif
    127147}
    128148
  • ttyvaders/trunk/src/main.c

    r62 r64  
    44 *                 All Rights Reserved
    55 *
    6  *   $Id: main.c,v 1.15 2002/12/23 15:06:13 sam Exp $
     6 *   $Id: main.c,v 1.16 2002/12/23 16:21:38 sam Exp $
    77 *
    88 *   This program is free software; you can redistribute it and/or modify
     
    2525
    2626#include <string.h>
    27 #include <unistd.h>
     27
     28#include <time.h>
    2829
    2930#include "common.h"
     
    3536    game *g = malloc(sizeof(game));
    3637
    37     //srand(time(NULL));
     38    srand(time(NULL));
    3839
    3940    if( init_graphics() )
     
    165166        }
    166167
    167         usleep(40000);
     168        gfx_delay();
    168169
    169170        if( !poz || skip )
     
    201202
    202203            update_explosions( g, g->ex );
    203             /*if(purcompteur%2)*/ update_tunnel( g, g->t );
     204            update_tunnel( g, g->t );
    204205        }
    205206
  • ttyvaders/trunk/src/overlay.c

    r62 r64  
    44 *                 All Rights Reserved
    55 *
    6  *   $Id: overlay.c,v 1.1 2002/12/23 15:06:13 sam Exp $
     6 *   $Id: overlay.c,v 1.2 2002/12/23 16:21:38 sam Exp $
    77 *
    88 *   This program is free software; you can redistribute it and/or modify
     
    3232    /* Draw life jauge */
    3333    gfx_color( GRAY );
    34     gfx_goto( 2, 1 );
     34    gfx_goto( 4, 1 );
    3535    gfx_putstr( dots30 );
    3636
     
    4848    }
    4949
    50     gfx_goto( 2, 1 );
     50    gfx_goto( 4, 1 );
    5151    gfx_putstr( dashes30 + ( MAX_LIFE - g->p->life ) * 30 / MAX_LIFE );
    5252
    5353    gfx_color( WHITE );
    5454    gfx_goto( 1, 1 );
     55    gfx_putstr( "L |" );
     56    gfx_goto( 34, 1 );
    5557    gfx_putstr( "|" );
    56     gfx_goto( 32, 1 );
    57     gfx_putstr( "| L" );
    5858
    5959    /* Draw weapon jauge */
    6060    gfx_color( GRAY );
    61     gfx_goto( 38, 1 );
     61    gfx_goto( 42, 1 );
    6262    gfx_putstr( dots30 + 10 );
    6363
     
    7575    }
    7676
    77     gfx_goto( 38, 1 );
     77    gfx_goto( 42, 1 );
    7878    gfx_putstr( dashes30 + 10 + ( MAX_SPECIAL - g->p->special ) * 20 / MAX_SPECIAL );
    7979
    8080    gfx_color( WHITE );
    81     gfx_goto( 37, 1 );
     81    gfx_goto( 39, 1 );
     82    gfx_putstr( "S |" );
     83    gfx_goto( 62, 1 );
    8284    gfx_putstr( "|" );
    83     gfx_goto( 58, 1 );
    84     gfx_putstr( "| S" );
    8585}
    8686
  • ttyvaders/trunk/src/player.c

    r62 r64  
    44 *                 All Rights Reserved
    55 *
    6  *   $Id: player.c,v 1.7 2002/12/23 15:06:13 sam Exp $
     6 *   $Id: player.c,v 1.8 2002/12/23 16:21:38 sam Exp $
    77 *
    88 *   This program is free software; you can redistribute it and/or modify
     
    3737    p->special = MAX_SPECIAL;
    3838    p->life = MAX_LIFE;
     39    p->dead = 0;
    3940
    4041    return p;
Note: See TracChangeset for help on using the changeset viewer.