diff --git a/configure.ac b/configure.ac index e1b364e..e543981 100644 --- a/configure.ac +++ b/configure.ac @@ -1,13 +1,13 @@ dnl Autoconf settings for ttyvaders -AC_INIT(ttyvaders,0.0cvs-20021218) +AC_INIT(ttyvaders,0.0cvs-20021223) AC_PREREQ(2.50) AC_CONFIG_SRCDIR(src/main.c) AC_CONFIG_AUX_DIR(autotools) AC_CANONICAL_SYSTEM -AM_INIT_AUTOMAKE(ttyvaders,0.0cvs-20021218) +AM_INIT_AUTOMAKE(ttyvaders,0.0cvs-20021223) AM_CONFIG_HEADER(config.h) AM_PROG_CC_C_O diff --git a/src/collide.c b/src/collide.c index fefbe17..8352435 100644 --- a/src/collide.c +++ b/src/collide.c @@ -3,7 +3,7 @@ * Copyright (c) 2002 Sam Hocevar * All Rights Reserved * - * $Id: collide.c,v 1.9 2002/12/23 13:46:27 sam Exp $ + * $Id: collide.c,v 1.10 2002/12/23 16:21:38 sam Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,6 +41,11 @@ void collide_weapons_tunnel( game *g, weapons *wp, tunnel *t, explosions *ex ) case WEAPON_SEEKER: case WEAPON_BOMB: case WEAPON_FRAGBOMB: + if( y < 0 || y >= g->h ) + { + break; + } + if( x <= t->left[y] || x >= t->right[y] ) { @@ -50,19 +55,19 @@ void collide_weapons_tunnel( game *g, weapons *wp, tunnel *t, explosions *ex ) if( x <= t->left[y] ) { - t->right[y-2] -= damage - 1; - t->left[y-1] -= damage; + if( y-2 >= 0 ) t->right[y-2] -= damage - 1; + if( y-1 >= 0 ) t->left[y-1] -= damage; t->left[y] -= damage + 1; - t->left[y+1] -= damage; - t->right[y+2] -= damage - 1; + if( y+1 < g->h ) t->left[y+1] -= damage; + if( y+2 < g->h ) t->right[y+2] -= damage - 1; } else { - t->right[y-2] += damage - 1; - t->right[y-1] += damage; + if( y-2 >= 0 ) t->right[y-2] += damage - 1; + if( y-1 >= 0 ) t->right[y-1] += damage; t->right[y] += damage + 1; - t->right[y+1] += damage; - t->right[y+2] += damage - 1; + if( y+1 < g->h ) t->right[y+1] += damage; + if( y+2 < g->h ) t->right[y+2] += damage - 1; } if( wp->type[i] == WEAPON_FRAGBOMB ) @@ -80,6 +85,11 @@ void collide_weapons_tunnel( game *g, weapons *wp, tunnel *t, explosions *ex ) j < GET_MAX( 0, wp->vy[i] >> 4 ) ; j++ ) { + if( y+j >= g->h || y+j < 0 ) + { + continue; + } + if( x <= t->left[y+j] || x >= t->right[y+j] ) { add_explosion( g, ex, x, y+j, 0, 1, EXPLOSION_SMALL ); @@ -87,15 +97,27 @@ void collide_weapons_tunnel( game *g, weapons *wp, tunnel *t, explosions *ex ) if( x <= t->left[y+j] ) { - t->left[y+j-1]--; + if( y+j-1 >= 0 ) + { + t->left[y+j-1]--; + } t->left[y+j] -= 2; - t->left[y+j+1]--; + if( y+j+1 < g->h ) + { + t->left[y+j+1]--; + } } else { - t->right[y+j-1]++; + if( y+j-1 >= 0 ) + { + t->right[y+j-1]++; + } t->right[y+j] += 2; - t->right[y+j+1]++; + if( y+j+1 < g->h ) + { + t->right[y+j+1]++; + } } break; } @@ -268,15 +290,17 @@ void collide_player_tunnel( game *g, player *p, tunnel *t, explosions *ex ) if( p->x <= t->left[p->y] ) { - p->x += 2; - add_explosion( g, ex, p->x+1, p->y-2, 0, 0, EXPLOSION_SMALL ); - p->life -= 50; + p->x += 3; + p->vx = 2; + add_explosion( g, ex, p->x+1, p->y-1, 0, 0, EXPLOSION_SMALL ); + p->life -= 80; } else if( p->x + 5 >= t->right[p->y] ) { - p->x -= 2; - add_explosion( g, ex, p->x+4, p->y-2, 0, 0, EXPLOSION_SMALL ); - p->life -= 50; + p->x -= 3; + p->vx = -2; + add_explosion( g, ex, p->x+4, p->y-1, 0, 0, EXPLOSION_SMALL ); + p->life -= 80; } } diff --git a/src/common.h b/src/common.h index af624a2..dad232e 100644 --- a/src/common.h +++ b/src/common.h @@ -3,7 +3,7 @@ * Copyright (c) 2002 Sam Hocevar * All Rights Reserved * - * $Id: common.h,v 1.14 2002/12/23 15:06:13 sam Exp $ + * $Id: common.h,v 1.15 2002/12/23 16:21:38 sam Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,10 +55,10 @@ # define gfx_putchar(x) addch(x) # define gfx_putstr(x) addstr(x) #else -# define gfx_color(x) do{}while(0) -# define gfx_goto(x,y) do{}while(0) -# define gfx_putchar(x) do{}while(0) -# define gfx_putstr(x) do{}while(0) +# define gfx_color(x) (void)(x) +# define gfx_goto(x,y) do{ (void)(x); (void)(y); } while(0) +# define gfx_putchar(x) (void)(x) +# define gfx_putstr(x) (void)(x) #endif #define gfx_putcharTO(x,y,c) do{ gfx_goto(x,y); gfx_putchar(c); }while(0) @@ -207,6 +207,7 @@ void update_explosions( game *g, explosions *ex ); int init_graphics( void ); void init_game( game *g ); char get_key( void ); +void gfx_delay( void ); void clear_graphics( void ); void refresh_graphics( void ); void end_graphics( void ); diff --git a/src/graphics.c b/src/graphics.c index ee0f8ff..8ea1aa2 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -3,7 +3,7 @@ * Copyright (c) 2002 Sam Hocevar * All Rights Reserved * - * $Id: graphics.c,v 1.5 2002/12/23 10:06:27 sam Exp $ + * $Id: graphics.c,v 1.6 2002/12/23 16:21:38 sam Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +20,10 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "config.h" + #include +#include #include "common.h" @@ -121,11 +124,28 @@ char get_key( void ) } #else /* Use dummy driver */ + char key = GET_RAND(0,256); + + if( key != 'q' && key != 'p' && key != '\t' ) + { + return key; + } #endif return 0; } +void gfx_delay( void ) +{ +#ifdef USE_SLANG + usleep(40000); +#elif USE_NCURSES + usleep(40000); +#else + /* Use dummy driver */ +#endif +} + void clear_graphics( void ) { #ifdef USE_SLANG diff --git a/src/main.c b/src/main.c index 1a912ae..31d4fd3 100644 --- a/src/main.c +++ b/src/main.c @@ -3,7 +3,7 @@ * Copyright (c) 2002 Sam Hocevar * All Rights Reserved * - * $Id: main.c,v 1.15 2002/12/23 15:06:13 sam Exp $ + * $Id: main.c,v 1.16 2002/12/23 16:21:38 sam Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,8 @@ #include #include -#include + +#include #include "common.h" @@ -34,7 +35,7 @@ int main (int argc, char **argv) { game *g = malloc(sizeof(game)); - //srand(time(NULL)); + srand(time(NULL)); if( init_graphics() ) { @@ -164,7 +165,7 @@ static void start_game (game *g) } } - usleep(40000); + gfx_delay(); if( !poz || skip ) { @@ -200,7 +201,7 @@ static void start_game (game *g) collide_weapons_aliens( g, g->wp, g->al, g->ex ); update_explosions( g, g->ex ); - /*if(purcompteur%2)*/ update_tunnel( g, g->t ); + update_tunnel( g, g->t ); } /* Clear screen */ diff --git a/src/overlay.c b/src/overlay.c index 3cc1f5f..c695235 100644 --- a/src/overlay.c +++ b/src/overlay.c @@ -3,7 +3,7 @@ * Copyright (c) 2002 Sam Hocevar * All Rights Reserved * - * $Id: overlay.c,v 1.1 2002/12/23 15:06:13 sam Exp $ + * $Id: overlay.c,v 1.2 2002/12/23 16:21:38 sam Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ void draw_overlay( game *g ) /* Draw life jauge */ gfx_color( GRAY ); - gfx_goto( 2, 1 ); + gfx_goto( 4, 1 ); gfx_putstr( dots30 ); if( g->p->life > MAX_LIFE * 7 / 10 ) @@ -47,18 +47,18 @@ void draw_overlay( game *g ) gfx_color( RED ); } - gfx_goto( 2, 1 ); + gfx_goto( 4, 1 ); gfx_putstr( dashes30 + ( MAX_LIFE - g->p->life ) * 30 / MAX_LIFE ); gfx_color( WHITE ); gfx_goto( 1, 1 ); + gfx_putstr( "L |" ); + gfx_goto( 34, 1 ); gfx_putstr( "|" ); - gfx_goto( 32, 1 ); - gfx_putstr( "| L" ); /* Draw weapon jauge */ gfx_color( GRAY ); - gfx_goto( 38, 1 ); + gfx_goto( 42, 1 ); gfx_putstr( dots30 + 10 ); if( g->p->special > MAX_SPECIAL * 9 / 10 ) @@ -74,13 +74,13 @@ void draw_overlay( game *g ) gfx_color( BLUE ); } - gfx_goto( 38, 1 ); + gfx_goto( 42, 1 ); gfx_putstr( dashes30 + 10 + ( MAX_SPECIAL - g->p->special ) * 20 / MAX_SPECIAL ); gfx_color( WHITE ); - gfx_goto( 37, 1 ); + gfx_goto( 39, 1 ); + gfx_putstr( "S |" ); + gfx_goto( 62, 1 ); gfx_putstr( "|" ); - gfx_goto( 58, 1 ); - gfx_putstr( "| S" ); } diff --git a/src/player.c b/src/player.c index 494f9c9..12f9070 100644 --- a/src/player.c +++ b/src/player.c @@ -3,7 +3,7 @@ * Copyright (c) 2002 Sam Hocevar * All Rights Reserved * - * $Id: player.c,v 1.7 2002/12/23 15:06:13 sam Exp $ + * $Id: player.c,v 1.8 2002/12/23 16:21:38 sam Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,6 +36,7 @@ player * create_player( game *g ) p->weapon = 0; p->special = MAX_SPECIAL; p->life = MAX_LIFE; + p->dead = 0; return p; }