* beam now collides with aliens. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@24 92316355-f0b4-4df1-b90c-862c8a59935fmaster
@@ -26,6 +26,10 @@ Aliens | |||
_o|o_ | |||
T|T | |||
_ | |||
,(|). / \ | |||
/,-'-.\ ,(_X_). | |||
Bonus | |||
----- | |||
_ _ _ | |||
@@ -61,12 +65,40 @@ Shots | |||
\ __ __ / | |||
| \ / | | |||
___ _, ._ ,^. _, ._ | |||
. o |___> / | | \ | | ,-' / \ `-. | |||
/ / \ \ |_| \,-' `-./ | |||
`' `' | |||
___ ,. ,. _ | |||
<___| \ \ / / | | /`-. ,-'\ | |||
\_| |_/ | | `-._\ /_,-' | |||
`v' ` ' | |||
| | | |||| |/\| | |||
|| || || |||||| ||/\|| | |||
| | | | | | | | |||
:%%: | |||
:%%: :%##%: | |||
__ __ __ ____ :%%: :%##%: :%####%: | |||
' ` -' `- ,-' `-. ,-' `-. ,-' `-. ,-' `-. ,-' `-. | |||
,--. | |||
( ) | |||
`--' | |||
o O | |||
o ° | |||
. ° | |||
. | |||
,--. | |||
( ) | |||
|||| | |||
|||| | |||
|| | |||
| | |||
Explosions | |||
---------- | |||
@@ -81,13 +81,13 @@ void add_alien( game *g, aliens *al, int x, int y, int type ) | |||
switch( al->type[i] ) | |||
{ | |||
case ALIEN_POOLP: | |||
al->life[i] = 2; | |||
al->life[i] = 3; | |||
break; | |||
case ALIEN_BOOL: | |||
al->life[i] = 2; | |||
al->life[i] = 3; | |||
break; | |||
case ALIEN_BRAH: | |||
al->life[i] = 2; | |||
al->life[i] = 3; | |||
break; | |||
case ALIEN_NONE: | |||
break; | |||
@@ -17,22 +17,29 @@ void collide_weapons_tunnel( game *g, weapons *wp, tunnel *t, explosions *ex ) | |||
case WEAPON_NONE: | |||
break; | |||
case WEAPON_SEEKER: | |||
case WEAPON_BOMB: | |||
if( x <= t->left[y] | |||
|| x >= t->right[y] ) | |||
{ | |||
add_explosion( g, ex, x, y, 0, 1, EXPLOSION_SMALL ); | |||
int damage = wp->type[i] == WEAPON_SEEKER ? 1 : 2; | |||
add_explosion( g, ex, x, y, 0, 1, wp->type[i] == WEAPON_SEEKER ? EXPLOSION_SMALL : EXPLOSION_MEDIUM ); | |||
if( x <= t->left[y] ) | |||
{ | |||
t->left[y-1]--; | |||
t->left[y]-=2; | |||
t->left[y+1]--; | |||
t->right[y-2] -= damage - 1; | |||
t->left[y-1] -= damage; | |||
t->left[y] -= damage + 1; | |||
t->left[y+1] -= damage; | |||
t->right[y+2] -= damage - 1; | |||
} | |||
else | |||
{ | |||
t->right[y-1]++; | |||
t->right[y]+=2; | |||
t->right[y+1]++; | |||
t->right[y-2] += damage - 1; | |||
t->right[y-1] += damage; | |||
t->right[y] += damage + 1; | |||
t->right[y+1] += damage; | |||
t->right[y+2] += damage - 1; | |||
} | |||
wp->type[i] = WEAPON_NONE; | |||
@@ -81,7 +88,8 @@ void collide_weapons_tunnel( game *g, weapons *wp, tunnel *t, explosions *ex ) | |||
} | |||
break; | |||
case WEAPON_NUKE: | |||
/* The nuke does not break the tunnel */ | |||
case WEAPON_BEAM: | |||
/* The nuke and the laser do not break the tunnel */ | |||
break; | |||
} | |||
} | |||
@@ -126,6 +134,30 @@ void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex ) | |||
} | |||
} | |||
break; | |||
case WEAPON_BEAM: | |||
r = (29 - wp->n[i]) * (29 - wp->n[i]) / 8; | |||
for( j = 0; j < ALIENS; j++ ) | |||
{ | |||
if( al->type[j] == ALIEN_NONE ) | |||
{ | |||
continue; | |||
} | |||
if( x >= al->x[j] && x <= al->x[j] + 4 | |||
&& y >= al->y[j] + 2 && y-5-r <= al->y[j] ) | |||
{ | |||
al->life[j] -= 4; | |||
if( al->life[j] <= 0 ) | |||
{ | |||
al->type[j] = ALIEN_NONE; | |||
add_explosion( g, ex, al->x[j], al->y[j], 0, 0, EXPLOSION_MEDIUM ); | |||
add_bonus( g, g->bo, al->x[j], al->y[j], GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE ); | |||
} | |||
} | |||
} | |||
break; | |||
case WEAPON_LASER: | |||
for( j = 0; j < ALIENS; j++ ) | |||
{ | |||
@@ -141,8 +173,8 @@ void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex ) | |||
if( al->life[j] <= 0 ) | |||
{ | |||
al->type[j] = ALIEN_NONE; | |||
add_explosion( g, ex, x, y, 0, 0, EXPLOSION_MEDIUM ); | |||
add_bonus( g, g->bo, x, y, GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE ); | |||
add_explosion( g, ex, al->x[j], al->y[j], 0, 0, EXPLOSION_MEDIUM ); | |||
add_bonus( g, g->bo, al->x[j], al->y[j], GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE ); | |||
} | |||
ok = 1; | |||
} | |||
@@ -153,8 +185,8 @@ void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex ) | |||
if( al->life[j] <= 0 ) | |||
{ | |||
al->type[j] = ALIEN_NONE; | |||
add_explosion( g, ex, x, y+1, 0, 0, EXPLOSION_MEDIUM ); | |||
add_bonus( g, g->bo, x, y+1, GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE ); | |||
add_explosion( g, ex, al->x[j], al->y[j]+1, 0, 0, EXPLOSION_MEDIUM ); | |||
add_bonus( g, g->bo, al->x[j], al->y[j]+1, GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE ); | |||
} | |||
ok = 1; | |||
} | |||
@@ -162,11 +194,13 @@ void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex ) | |||
if( ok ) | |||
{ | |||
add_explosion( g, ex, x, y+1, 0, 0, EXPLOSION_SMALL ); | |||
wp->type[i] = WEAPON_NONE; | |||
} | |||
break; | |||
case WEAPON_SEEKER: | |||
case WEAPON_BOMB: | |||
for( j = 0; j < ALIENS; j++ ) | |||
{ | |||
if( al->type[j] == ALIEN_NONE ) | |||
@@ -181,8 +215,8 @@ void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex ) | |||
if( al->life[j] <= 0 ) | |||
{ | |||
al->type[j] = ALIEN_NONE; | |||
add_explosion( g, ex, x, y, 0, 0, EXPLOSION_MEDIUM ); | |||
add_bonus( g, g->bo, x, y, GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE ); | |||
add_explosion( g, ex, al->x[j], al->y[j], 0, 0, EXPLOSION_MEDIUM ); | |||
add_bonus( g, g->bo, al->x[j], al->y[j], GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE ); | |||
} | |||
ok = 1; | |||
} | |||
@@ -190,6 +224,7 @@ void collide_weapons_aliens( game *g, weapons *wp, aliens *al, explosions *ex ) | |||
if( ok ) | |||
{ | |||
add_explosion( g, ex, x, y+1, 0, 0, wp->type[i] == WEAPON_SEEKER ? EXPLOSION_SMALL : EXPLOSION_MEDIUM ); | |||
wp->type[i] = WEAPON_NONE; | |||
} | |||
break; | |||
@@ -1,9 +1,9 @@ | |||
#define STARS 50 | |||
#define WEAPONS 50 | |||
#define WEAPONS 100 | |||
#define BONUS 30 | |||
#define ALIENS 30 | |||
#define EXPLOSIONS 20 | |||
#define EXPLOSIONS 100 | |||
#ifdef USE_SLANG | |||
# include <slang.h> | |||
@@ -52,7 +52,7 @@ typedef struct | |||
typedef struct | |||
{ | |||
enum { WEAPON_NONE, WEAPON_LASER, WEAPON_SEEKER, WEAPON_NUKE, WEAPON_BEAM } type[WEAPONS]; | |||
enum { WEAPON_NONE, WEAPON_LASER, WEAPON_SEEKER, WEAPON_NUKE, WEAPON_BEAM, WEAPON_LIGHTNING, WEAPON_BOMB } type[WEAPONS]; | |||
int x[WEAPONS]; | |||
int y[WEAPONS]; | |||
int x2[WEAPONS]; | |||
@@ -127,8 +127,7 @@ 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, -24, -16, WEAPON_SEEKER ); | |||
add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 24, -16, WEAPON_SEEKER ); | |||
add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, -16, WEAPON_BOMB ); | |||
} | |||
case ' ': | |||
if( g->p->weapon == 0 ) | |||
@@ -136,6 +135,18 @@ static void start_game (game *g) | |||
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 ); | |||
/* 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 ); | |||
/* 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 ); | |||
/* 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 ); | |||
} | |||
break; | |||
} | |||
@@ -143,48 +154,42 @@ static void start_game (game *g) | |||
usleep(40000); | |||
if( GET_RAND(0,10) == 0 ) | |||
if( !poz || skip ) | |||
{ | |||
int list[3] = { ALIEN_POOLP, ALIEN_BOOL, ALIEN_BRAH }; | |||
skip = 0; | |||
add_alien( g, g->al, 0, rand() % g->h / 2, list[GET_RAND(0,3)] ); | |||
} | |||
if( poz ) | |||
{ | |||
if( skip ) | |||
/* XXX: to be removed */ | |||
if( GET_RAND(0,10) == 0 ) | |||
{ | |||
skip = 0; | |||
int list[3] = { ALIEN_POOLP, ALIEN_BOOL, ALIEN_BRAH }; | |||
add_alien( g, g->al, 0, rand() % g->h / 2, list[GET_RAND(0,3)] ); | |||
} | |||
else | |||
/* Update game rules */ | |||
if( g->t->right[1] - g->t->left[1] == g->t->w ) | |||
{ | |||
continue; | |||
g->t->w = 85 - g->t->w; | |||
} | |||
} | |||
/* Update game rules */ | |||
if( g->t->right[1] - g->t->left[1] == g->t->w ) | |||
{ | |||
g->t->w = 85 - g->t->w; | |||
} | |||
/* Scroll and update positions */ | |||
collide_player_tunnel( g, g->p, g->t, g->ex ); | |||
update_player( g, g->p ); | |||
collide_player_tunnel( g, g->p, g->t, g->ex ); | |||
/* Scroll and update positions */ | |||
collide_player_tunnel( g, g->p, g->t, g->ex ); | |||
update_player( g, g->p ); | |||
collide_player_tunnel( g, g->p, g->t, g->ex ); | |||
update_starfield( g, g->sf ); | |||
update_bonus( g, g->bo ); | |||
update_aliens( g, g->al ); | |||
update_starfield( g, g->sf ); | |||
update_bonus( g, g->bo ); | |||
update_aliens( g, g->al ); | |||
collide_weapons_tunnel( g, g->wp, g->t, g->ex ); | |||
collide_weapons_aliens( g, g->wp, g->al, g->ex ); | |||
update_weapons( g, g->wp ); | |||
collide_weapons_tunnel( g, g->wp, g->t, g->ex ); | |||
collide_weapons_aliens( g, g->wp, g->al, g->ex ); | |||
collide_weapons_tunnel( g, g->wp, g->t, g->ex ); | |||
collide_weapons_aliens( g, g->wp, g->al, g->ex ); | |||
update_weapons( g, g->wp ); | |||
collide_weapons_tunnel( g, g->wp, g->t, g->ex ); | |||
collide_weapons_aliens( g, g->wp, g->al, g->ex ); | |||
update_explosions( g, g->ex ); | |||
/*if(purcompteur%2)*/ update_tunnel( g, g->t ); | |||
update_explosions( g, g->ex ); | |||
/*if(purcompteur%2)*/ update_tunnel( g, g->t ); | |||
} | |||
/* Clear screen */ | |||
clear_graphics(); | |||
@@ -195,8 +200,8 @@ static void start_game (game *g) | |||
draw_bonus( g, g->bo ); | |||
draw_aliens( g, g->al ); | |||
draw_player( g, g->p ); | |||
draw_weapons( g, g->wp ); | |||
draw_explosions( g, g->ex ); | |||
draw_weapons( g, g->wp ); | |||
/* Refresh */ | |||
refresh_graphics(); | |||
@@ -4,6 +4,7 @@ | |||
#include "common.h" | |||
static void draw_bomb( int x, int y, int vx, int vy ); | |||
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 ); | |||
@@ -44,6 +45,20 @@ void draw_weapons( game *g, weapons *wp ) | |||
gfx_goto( wp->x[i] >> 4, wp->y[i] >> 4 ); | |||
gfx_putchar( '@' ); | |||
break; | |||
case WEAPON_BOMB: | |||
gfx_color( GRAY ); | |||
gfx_goto( (wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4 ); | |||
gfx_putchar( '.' ); | |||
gfx_goto( (wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4 ); | |||
gfx_putchar( '.' ); | |||
gfx_goto( (wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4 ); | |||
gfx_putchar( '.' ); | |||
gfx_goto( wp->x3[i] >> 4, wp->y3[i] >> 4 ); | |||
gfx_putchar( '.' ); | |||
gfx_goto( wp->x2[i] >> 4, wp->y2[i] >> 4 ); | |||
gfx_putchar( '.' ); | |||
draw_bomb( wp->x[i] >> 4, wp->y[i] >> 4, wp->vx[i], wp->vy[i] ); | |||
break; | |||
case WEAPON_BEAM: | |||
draw_beam( wp->x[i] >> 4, wp->y[i] >> 4, wp->n[i] ); | |||
break; | |||
@@ -72,6 +87,7 @@ void update_weapons( game *g, weapons *wp ) | |||
wp->type[i] = WEAPON_NONE; | |||
} | |||
break; | |||
case WEAPON_BOMB: | |||
case WEAPON_SEEKER: | |||
/* Update tail */ | |||
wp->x3[i] = wp->x2[i]; | |||
@@ -175,6 +191,7 @@ void add_weapon( game *g, weapons *wp, int x, int y, int vx, int vy, int type ) | |||
case WEAPON_LASER: | |||
break; | |||
case WEAPON_SEEKER: | |||
case WEAPON_BOMB: | |||
wp->x2[i] = x; | |||
wp->y2[i] = y; | |||
wp->x3[i] = x; | |||
@@ -195,6 +212,153 @@ void add_weapon( game *g, weapons *wp, int x, int y, int vx, int vy, int type ) | |||
} | |||
} | |||
static void draw_bomb( int x, int y, int vx, int vy ) | |||
{ | |||
vy *= 2; | |||
gfx_color( CYAN ); | |||
if( vx > vy ) | |||
{ | |||
if( vx > -vy ) /* right quarter */ | |||
{ | |||
if( vy > vx/4 ) | |||
{ | |||
/* -1pi/6 */ | |||
gfx_goto( x-4, y-1 ); | |||
gfx_putstr( "/`-." ); | |||
gfx_goto( x-4, y ); | |||
gfx_putstr( "`-._\\" ); | |||
gfx_goto( x, y+1 ); | |||
gfx_putchar( '`' ); | |||
} | |||
else if( vy < -vx/4 ) | |||
{ | |||
/* 1pi/6 */ | |||
gfx_goto( x-1, y-1 ); | |||
gfx_putstr( "_," ); | |||
gfx_goto( x-4, y ); | |||
gfx_putstr( ",-' /" ); | |||
gfx_goto( x-4, y+1 ); | |||
gfx_putstr( "\\,-'" ); | |||
} | |||
else | |||
{ | |||
/* 0pi/6 */ | |||
gfx_goto( x-4, y-1 ); | |||
gfx_putstr( "____" ); | |||
gfx_goto( x-5, y ); | |||
gfx_putstr( "|____>" ); | |||
} | |||
} | |||
else /* top quarter */ | |||
{ | |||
if( vx > -vy/4 ) | |||
{ | |||
/* 2pi/6 */ | |||
gfx_goto( x-1, y-1 ); | |||
gfx_putstr( "_," ); | |||
gfx_goto( x-2, y ); | |||
gfx_putstr( "/ |" ); | |||
gfx_goto( x-3, y+1 ); | |||
gfx_putstr( "/ /" ); | |||
gfx_goto( x-3, y+2 ); | |||
gfx_putstr( "`'" ); | |||
} | |||
else if( vx < vy/4 ) | |||
{ | |||
/* 4pi/6 */ | |||
gfx_goto( x, y-1 ); | |||
gfx_putstr( "._" ); | |||
gfx_goto( x, y ); | |||
gfx_putstr( "| \\" ); | |||
gfx_goto( x+1, y+1 ); | |||
gfx_putstr( "\\ \\" ); | |||
gfx_goto( x+2, y+2 ); | |||
gfx_putstr( "`'" ); | |||
} | |||
else | |||
{ | |||
/* 3pi/6 */ | |||
gfx_goto( x-1, y ); | |||
gfx_putstr( ",^." ); | |||
gfx_goto( x-1, y+1 ); | |||
gfx_putstr( "| |" ); | |||
gfx_goto( x-1, y+2 ); | |||
gfx_putstr( "|_|" ); | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
if( vx > -vy ) /* bottom quarter */ | |||
{ | |||
if( vx > vy/4 ) | |||
{ | |||
/* -2pi/6 */ | |||
gfx_goto( x-2, y-2 ); | |||
gfx_putstr( ",." ); | |||
gfx_goto( x-2, y-1 ); | |||
gfx_putstr( "\\ \\" ); | |||
gfx_goto( x-1, y ); | |||
gfx_putstr( "\\_|" ); | |||
} | |||
else if( vx < -vy/4 ) | |||
{ | |||
/* -4pi/6 */ | |||
gfx_goto( x+1, y-2 ); | |||
gfx_putstr( ",." ); | |||
gfx_goto( x, y-1 ); | |||
gfx_putstr( "/ /" ); | |||
gfx_goto( x-1, y ); | |||
gfx_putstr( "|_/" ); | |||
} | |||
else | |||
{ | |||
/* -3pi/6 */ | |||
gfx_goto( x, y-3 ); | |||
gfx_putchar( '_' ); | |||
gfx_goto( x-1, y-2 ); | |||
gfx_putstr( "| |" ); | |||
gfx_goto( x-1, y-1 ); | |||
gfx_putstr( "| |" ); | |||
gfx_goto( x-1, y ); | |||
gfx_putstr( "`v'" ); | |||
} | |||
} | |||
else /* left quarter */ | |||
{ | |||
if( vy > -vx/4 ) | |||
{ | |||
/* -5pi/6 */ | |||
gfx_goto( x+1, y-1 ); | |||
gfx_putstr( ",-'\\" ); | |||
gfx_goto( x, y ); | |||
gfx_putstr( "/_,-'" ); | |||
gfx_goto( x, y+1 ); | |||
gfx_putchar( '\'' ); | |||
} | |||
else if( vy < vx/4 ) | |||
{ | |||
/* 5pi/6 */ | |||
gfx_goto( x, y-1 ); | |||
gfx_putstr( "._" ); | |||
gfx_goto( x, y ); | |||
gfx_putstr( "\\ `-." ); | |||
gfx_goto( x+1, y+1 ); | |||
gfx_putstr( "`-./" ); | |||
} | |||
else | |||
{ | |||
/* 6pi/6 */ | |||
gfx_goto( x+1, y-1 ); | |||
gfx_putstr( "____" ); | |||
gfx_goto( x, y ); | |||
gfx_putstr( "<____|" ); | |||
} | |||
} | |||
} | |||
} | |||
static void draw_beam( int x, int y, int frame ) | |||
{ | |||
int r = (29 - frame) * (29 - frame) / 8; | |||