Show small bullet hit effects when a target is struck.
This commit is contained in:
parent
5c211a3017
commit
157f1bc28a
|
@ -24,6 +24,7 @@ static void huntTarget(Bullet *b);
|
|||
static void checkCollisions(Bullet *b);
|
||||
static void resizeDrawList(void);
|
||||
static void selectNewTarget(Bullet *b);
|
||||
static void doBulletHitEffect(Bullet *b);
|
||||
|
||||
static Bullet bulletDef[BT_MAX];
|
||||
static Bullet **bulletsToDraw;
|
||||
|
@ -194,6 +195,8 @@ static void checkCollisions(Bullet *b)
|
|||
|
||||
damageFighter(e, b->damage, b->flags);
|
||||
|
||||
doBulletHitEffect(b);
|
||||
|
||||
b->life = 0;
|
||||
b->damage = 0;
|
||||
|
||||
|
@ -253,6 +256,32 @@ static void checkCollisions(Bullet *b)
|
|||
}
|
||||
}
|
||||
|
||||
void doBulletHitEffect(Bullet *b)
|
||||
{
|
||||
switch (b->type)
|
||||
{
|
||||
case BT_PARTICLE:
|
||||
addBulletHitEffect(b->x, b->y, 255, 0, 255);
|
||||
break;
|
||||
|
||||
case BT_PLASMA:
|
||||
addBulletHitEffect(b->x, b->y, 0, 255, 0);
|
||||
break;
|
||||
|
||||
case BT_LASER:
|
||||
addBulletHitEffect(b->x, b->y, 255, 0, 0);
|
||||
break;
|
||||
|
||||
case BT_MAG:
|
||||
addBulletHitEffect(b->x, b->y, 196, 196, 255);
|
||||
break;
|
||||
|
||||
default:
|
||||
addBulletHitEffect(b->x, b->y, 255, 255, 255);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void drawBullets(void)
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -49,6 +49,7 @@ extern void *resize(void *array, int oldSize, int newSize);
|
|||
extern void awardTrophy(char *id);
|
||||
extern int isOnBattleScreen(int x, int y, int w, int h);
|
||||
extern int getDistance(int x1, int y1, int x2, int y2);
|
||||
extern void addBulletHitEffect(int x, int y, int r, int g, int b);
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
|
|
|
@ -179,6 +179,37 @@ void drawShieldHitEffect(Entity *e)
|
|||
blit(shieldHitTexture, e->x - battle.camera.x, e->y - battle.camera.y, 1);
|
||||
}
|
||||
|
||||
void addBulletHitEffect(int x, int y, int r, int g, int b)
|
||||
{
|
||||
Effect *e;
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < 4 ; i++)
|
||||
{
|
||||
e = malloc(sizeof(Effect));
|
||||
memset(e, 0, sizeof(Effect));
|
||||
battle.effectTail->next = e;
|
||||
battle.effectTail = e;
|
||||
|
||||
e->type = EFFECT_TEXTURE;
|
||||
e->texture = explosionTexture;
|
||||
e->size = 16;
|
||||
e->x = x;
|
||||
e->y = y;
|
||||
|
||||
e->dx = (rand() % 25) - (rand() % 25);
|
||||
e->dx *= 0.01;
|
||||
e->dy = (rand() % 25) - (rand() % 25);
|
||||
e->dy *= 0.01;
|
||||
|
||||
e->r = r;
|
||||
e->g = g;
|
||||
e->b = b;
|
||||
e->a = 64;
|
||||
e->health = e->a;
|
||||
}
|
||||
}
|
||||
|
||||
void addSmallFighterExplosion(void)
|
||||
{
|
||||
Effect *e;
|
||||
|
|
Loading…
Reference in New Issue