From dcbea62140160b5eb4835bd0b1d5e50b3437e4f4 Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 23 Dec 2002 12:03:31 +0000 Subject: [PATCH] * lasers are now twice as fast. * walls are now filled, and displayed on top of aliens. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@54 92316355-f0b4-4df1-b90c-862c8a59935f --- src/main.c | 23 ++++++++----------- src/tunnel.c | 62 +++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 58 insertions(+), 27 deletions(-) diff --git a/src/main.c b/src/main.c index e7954ca..710b686 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.10 2002/12/23 10:06:27 sam Exp $ + * $Id: main.c,v 1.11 2002/12/23 12:03:31 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 @@ -75,11 +75,6 @@ static void start_game (game *g) init_aliens( g, g->al ); /* Temporary stuff */ - for( i = 0; i < 5; i++ ) - { - add_alien( g, g->al, rand() % g->w, rand() % g->h / 2, ALIEN_POOLP ); - } - g->t->w = 25; while( !quit ) @@ -146,17 +141,17 @@ static void start_game (game *g) if( g->p->weapon == 0 ) { g->p->weapon = 4; - add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, 0, -16, WEAPON_LASER ); - add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 0, -16, WEAPON_LASER ); + add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, 0, -32, WEAPON_LASER ); + add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 0, -32, WEAPON_LASER ); /* Extra shtuph */ add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, -24, -16, WEAPON_SEEKER ); add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 24, -16, WEAPON_SEEKER ); /* More shtuph */ - add_weapon( g, g->wp, (g->p->x + 1) << 4, (g->p->y - 1) << 4, 0, -16, WEAPON_LASER ); - add_weapon( g, g->wp, (g->p->x + 4) << 4, (g->p->y - 1) << 4, 0, -16, WEAPON_LASER ); + add_weapon( g, g->wp, (g->p->x + 1) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER ); + add_weapon( g, g->wp, (g->p->x + 4) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER ); /* Even more shtuph */ - add_weapon( g, g->wp, (g->p->x + 2) << 4, (g->p->y - 1) << 4, 0, -16, WEAPON_LASER ); - add_weapon( g, g->wp, (g->p->x + 3) << 4, (g->p->y - 1) << 4, 0, -16, WEAPON_LASER ); + add_weapon( g, g->wp, (g->p->x + 2) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER ); + add_weapon( g, g->wp, (g->p->x + 3) << 4, (g->p->y - 1) << 4, 0, -32, WEAPON_LASER ); /* Extra shtuph */ add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, -32, 0, WEAPON_SEEKER ); add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 32, 0, WEAPON_SEEKER ); @@ -209,9 +204,9 @@ static void start_game (game *g) /* Print starfield, tunnel, aliens, player and explosions */ draw_starfield( g, g->sf ); + draw_aliens( g, g->al ); draw_tunnel( g, g->t ); draw_bonus( g, g->bo ); - draw_aliens( g, g->al ); draw_explosions( g, g->ex ); draw_weapons( g, g->wp ); draw_player( g, g->p ); @@ -224,6 +219,6 @@ static void start_game (game *g) free_starfield( g, g->sf ); free_tunnel( g->t ); -// free_player( g->p ); + free_player( g->p ); } diff --git a/src/tunnel.c b/src/tunnel.c index 57907be..09906f7 100644 --- a/src/tunnel.c +++ b/src/tunnel.c @@ -3,7 +3,7 @@ * Copyright (c) 2002 Sam Hocevar * All Rights Reserved * - * $Id: tunnel.c,v 1.6 2002/12/23 10:06:27 sam Exp $ + * $Id: tunnel.c,v 1.7 2002/12/23 12:03:31 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 @@ -69,7 +69,7 @@ void free_tunnel( tunnel *t ) void draw_tunnel( game *g, tunnel *t ) { /* Print tunnel */ - draw_wall( g, t->left, -2 ); + draw_wall( g, t->left, 1 ); draw_wall( g, t->right, -1 ); } @@ -151,37 +151,73 @@ void update_tunnel( game *g, tunnel *t ) static void draw_wall( game *g, int *wall, int delta ) { - int i; + int i, j; gfx_color( RED ); + if( delta == -1 ) + { + for( i = 0; i < g->h ; i++ ) + { + for( j = wall[i] ; j < g->w ; j++ ) + { + gfx_goto( j, i ); + gfx_putchar( '#' ); + } + } + } + else + { + for( i = 0; i < g->h ; i++ ) + { + for( j = 0 ; j <= wall[i]; j++ ) + { + gfx_goto( j, i ); + gfx_putchar( '#' ); + } + } + } + + gfx_color( GREEN ); + for( i = 0; i < g->h ; i++ ) { - char *str; + char c; - if( wall[i] < -10 || wall[i] >= g->w + 10 ) + if( wall[i] <= -10 || wall[i] >= g->w + 10 ) { continue; } - if( wall[i] > wall[i+1] ) + if( i + 1 == g->h || wall[i] > wall[i+1] ) { - str = wall[i] > wall[i-1] ? ">##>" : "/##/"; + c = ( i == 0 || wall[i] > wall[i-1] ) ? '>' : '/'; } else { - str = wall[i] > wall[i-1] ? "\\##\\" : "<##<"; + c = ( i == 0 || wall[i] > wall[i-1] ) ? '\\' : '<'; } - if( wall[i] == wall[i+1] + 2 ) + if( delta == -1 && i + 1 < g->h ) { - gfx_goto( wall[i] - 1 + delta, i ); - gfx_putchar( '_' ); + for( j = 1; j < wall[i] - wall[i+1]; j++ ) + { + gfx_goto( wall[i+1] + j - 1, i ); + gfx_putchar( '_' ); + } } gfx_goto( wall[i] + delta, i ); - gfx_putstr( str ); - if( wall[i] == wall[i+1] - 2 ) gfx_putchar( '_' ); + gfx_putchar( c ); + + if( delta == +1 && i + 1 < g->h ) + { + for( j = 1; j < wall[i+1] - wall[i]; j++ ) + { + gfx_goto( wall[i] + j + 1, i ); + gfx_putchar( '_' ); + } + } } }