From 453d6f12e93d9bebdaeb55c16c809e090bebe33f Mon Sep 17 00:00:00 2001 From: sam Date: Sun, 15 Dec 2002 05:03:55 +0000 Subject: [PATCH] * 'beam' weapon. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@22 92316355-f0b4-4df1-b90c-862c8a59935f --- doc/shapes.txt | 79 +++++++------------------ src/common.h | 2 +- src/main.c | 9 ++- src/weapons.c | 155 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 184 insertions(+), 61 deletions(-) diff --git a/doc/shapes.txt b/doc/shapes.txt index fa8d61c..259a7b5 100644 --- a/doc/shapes.txt +++ b/doc/shapes.txt @@ -62,6 +62,11 @@ Shots | \ / | + :%%: + :%%: :%##%: + __ __ __ ____ :%%: :%##%: :%####%: + ' ` -' `- ,-' `-. ,-' `-. ,-' `-. ,-' `-. ,-' `-. + Explosions ---------- @@ -105,64 +110,20 @@ Explosions `-._______,-' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Bosses +------ + _,--._ + ,' `. + |\ / ,-. ,-. \ /| + )o),/ ( ( o )( o ) ) \.(o( + /o/// /| `-' `-' |\ \\\o\ + / / |\ \( . , )/ /| \ \ + | | \o`-/ `\/' \-'o/ | | + \ \ `,' `.' / / + \. \ `-' ,'| /\ |`. `-' / ,/ + \`. `.__,' / / \ \ `.__,' ,'/ + \o\ ,' ,' `. `. /o/ + \o`---' ,' `. `---'o/ + `.____,' `.____,' diff --git a/src/common.h b/src/common.h index 2b48944..fafd1ab 100644 --- a/src/common.h +++ b/src/common.h @@ -52,7 +52,7 @@ typedef struct typedef struct { - enum { WEAPON_NONE, WEAPON_LASER, WEAPON_SEEKER, WEAPON_NUKE } type[WEAPONS]; + enum { WEAPON_NONE, WEAPON_LASER, WEAPON_SEEKER, WEAPON_NUKE, WEAPON_BEAM } type[WEAPONS]; int x[WEAPONS]; int y[WEAPONS]; int x2[WEAPONS]; diff --git a/src/main.c b/src/main.c index 5116750..d874b96 100644 --- a/src/main.c +++ b/src/main.c @@ -109,13 +109,20 @@ static void start_game (game *g) case 'l': g->p->dir = 3; break; - case '\r': + case 'n': if( g->p->nuke == 0 ) { g->p->nuke = 40; add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, 0, WEAPON_NUKE ); } break; + case '\r': + if( g->p->nuke == 0 ) + { + g->p->nuke = 40; + add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, 0, WEAPON_BEAM ); + } + break; case 'b': if( g->p->weapon == 0 ) { diff --git a/src/weapons.c b/src/weapons.c index c6f4f2f..28c588d 100644 --- a/src/weapons.c +++ b/src/weapons.c @@ -5,6 +5,7 @@ #include "common.h" static void draw_nuke( int x, int y, int frame ); +static void draw_beam( int x, int y, int frame ); static void draw_circle( int x, int y, int r, char c ); void init_weapons( game *g, weapons *wp ) @@ -43,6 +44,9 @@ void draw_weapons( game *g, weapons *wp ) gfx_goto( wp->x[i] >> 4, wp->y[i] >> 4 ); gfx_putchar( '@' ); break; + case WEAPON_BEAM: + draw_beam( wp->x[i] >> 4, wp->y[i] >> 4, wp->n[i] ); + break; case WEAPON_NUKE: draw_nuke( wp->x[i] >> 4, wp->y[i] >> 4, wp->n[i] ); break; @@ -130,6 +134,15 @@ void update_weapons( game *g, weapons *wp ) wp->vy[i] = (7 * wp->vy[i] + (dy * 24) / sqrt(dx*dx+dy*dy) ) / 8; + break; + case WEAPON_BEAM: + wp->x[i] = (g->p->x + 2) << 4; + wp->y[i] = g->p->y << 4; + wp->n[i]--; + if( wp->n[i] < 0 ) + { + wp->type[i] = WEAPON_NONE; + } break; case WEAPON_NUKE: wp->n[i]--; @@ -168,6 +181,9 @@ void add_weapon( game *g, weapons *wp, int x, int y, int vx, int vy, int type ) wp->y3[i] = y; wp->n[i] = 10; break; + case WEAPON_BEAM: + wp->n[i] = 25; + break; case WEAPON_NUKE: wp->n[i] = 25; break; @@ -179,6 +195,145 @@ void add_weapon( game *g, weapons *wp, int x, int y, int vx, int vy, int type ) } } +static void draw_beam( int x, int y, int frame ) +{ + int r = (29 - frame) * (29 - frame) / 8; + int i; + + switch( frame ) + { + case 24: + gfx_color( WHITE ); + gfx_goto( x, y-3 ); + gfx_putstr( "__" ); + gfx_goto( x-1, y-2 ); + gfx_putchar( '\'' ); + gfx_goto( x+2, y-2 ); + gfx_putchar( '`' ); + break; + case 23: + gfx_color( CYAN ); + gfx_goto( x, y-3 ); + gfx_putstr( "__" ); + gfx_color( WHITE ); + gfx_goto( x-2, y-2 ); + gfx_putstr( "-'" ); + gfx_goto( x+2, y-2 ); + gfx_putstr( "`-" ); + break; + case 22: + gfx_color( CYAN ); + gfx_goto( x, y-3 ); + gfx_putstr( "__" ); + gfx_goto( x-1, y-2 ); + gfx_putchar( '\'' ); + gfx_goto( x+2, y-2 ); + gfx_putchar( '`' ); + gfx_color( WHITE ); + gfx_goto( x-3, y-2 ); + gfx_putstr( ",-" ); + gfx_goto( x+3, y-2 ); + gfx_putstr( "-." ); + break; + case 21: + gfx_color( CYAN ); + gfx_goto( x-1, y-3 ); + gfx_putstr( "____" ); + gfx_goto( x-2, y-2 ); + gfx_putchar( '\'' ); + gfx_goto( x+3, y-2 ); + gfx_putchar( '`' ); + gfx_color( WHITE ); + gfx_goto( x-4, y-2 ); + gfx_putstr( ",-" ); + gfx_goto( x+4, y-2 ); + gfx_putstr( "-." ); + break; + case 20: + gfx_color( WHITE ); + gfx_goto( x, y-3 ); + gfx_putstr( "%%" ); + gfx_goto( x-4, y-2 ); + gfx_putchar( ',' ); + gfx_goto( x+5, y-2 ); + gfx_putchar( '.' ); + gfx_color( CYAN ); + gfx_goto( x-1, y-3 ); + gfx_putchar( ':' ); + gfx_goto( x+2, y-3 ); + gfx_putchar( ':' ); + gfx_goto( x-3, y-2 ); + gfx_putstr( "-'" ); + gfx_goto( x+3, y-2 ); + gfx_putstr( "`-" ); + break; + case 19: + gfx_color( WHITE ); + gfx_goto( x, y-4 ); + gfx_putstr( "%%" ); + gfx_goto( x, y-3 ); + gfx_putstr( "##" ); + gfx_color( CYAN ); + gfx_goto( x-1, y-4 ); + gfx_putchar( ':' ); + gfx_goto( x+2, y-4 ); + gfx_putchar( ':' ); + gfx_goto( x-1, y-3 ); + gfx_putchar( '%' ); + gfx_goto( x+2, y-3 ); + gfx_putchar( '%' ); + gfx_goto( x-4, y-2 ); + gfx_putstr( ",-'" ); + gfx_goto( x+3, y-2 ); + gfx_putstr( "`-." ); + gfx_color( BLUE ); + gfx_goto( x-2, y-3 ); + gfx_putchar( ':' ); + gfx_goto( x+3, y-3 ); + gfx_putchar( ':' ); + break; + case 18: + default: + r = (18 - frame) * (18 - frame); + gfx_color( WHITE ); + gfx_goto( x-1, y-5-r ); + gfx_putstr( ":%%:" ); + gfx_goto( x-1, y-4-r ); + gfx_putstr( "%##%" ); + gfx_color( CYAN ); + gfx_goto( x-2, y-4-r ); + gfx_putchar( ':' ); + gfx_goto( x+3, y-4-r ); + gfx_putchar( ':' ); + gfx_goto( x-2, y-2 ); + gfx_putchar( '\'' ); + gfx_goto( x+3, y-2 ); + gfx_putchar( '`' ); + gfx_color( BLUE ); + gfx_goto( x-3, y-2 ); + gfx_putchar( ':' ); + gfx_goto( x+4, y-2 ); + gfx_putchar( ':' ); + for( i = 0; i <= r; i++ ) + { + gfx_color( WHITE ); + gfx_goto( x-1, y-3-i ); + gfx_putstr( "####" ); + gfx_color( CYAN ); + gfx_goto( x-2, y-3-i ); + gfx_putchar( '%' ); + gfx_goto( x+3, y-3-i ); + gfx_putchar( '%' ); + gfx_color( BLUE ); + gfx_goto( x-3, y-3-i ); + gfx_putchar( ':' ); + gfx_goto( x+4, y-3-i ); + gfx_putchar( ':' ); + } + break; + } +} + static void draw_nuke( int x, int y, int frame ) { int r = (29 - frame) * (29 - frame) / 8;