Bläddra i källkod

* 'beam' weapon.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@22 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 22 år sedan
förälder
incheckning
453d6f12e9
4 ändrade filer med 184 tillägg och 61 borttagningar
  1. +20
    -59
      doc/shapes.txt
  2. +1
    -1
      src/common.h
  3. +8
    -1
      src/main.c
  4. +155
    -0
      src/weapons.c

+ 20
- 59
doc/shapes.txt Visa fil

@@ -62,6 +62,11 @@ Shots
| \ / |


:%%:
:%%: :%##%:
__ __ __ ____ :%%: :%##%: :%####%:
' ` -' `- ,-' `-. ,-' `-. ,-' `-. ,-' `-. ,-' `-.

Explosions
----------

@@ -105,64 +110,20 @@ Explosions
`-._______,-'




























































Bosses
------

_,--._
,' `.
|\ / ,-. ,-. \ /|
)o),/ ( ( o )( o ) ) \.(o(
/o/// /| `-' `-' |\ \\\o\
/ / |\ \( . , )/ /| \ \
| | \o`-/ `\/' \-'o/ | |
\ \ `,' `.' / /
\. \ `-' ,'| /\ |`. `-' / ,/
\`. `.__,' / / \ \ `.__,' ,'/
\o\ ,' ,' `. `. /o/
\o`---' ,' `. `---'o/
`.____,' `.____,'


+ 1
- 1
src/common.h Visa fil

@@ -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];


+ 8
- 1
src/main.c Visa fil

@@ -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 )
{


+ 155
- 0
src/weapons.c Visa fil

@@ -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;


Laddar…
Avbryt
Spara