diff --git a/src/battle/bullets.c b/src/battle/bullets.c index d6b8cf6..2e9b241 100644 --- a/src/battle/bullets.c +++ b/src/battle/bullets.c @@ -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; @@ -193,6 +194,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; diff --git a/src/battle/bullets.h b/src/battle/bullets.h index a7868d7..a74a80d 100644 --- a/src/battle/bullets.h +++ b/src/battle/bullets.h @@ -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; diff --git a/src/battle/effects.c b/src/battle/effects.c index b0f0efb..2211698 100644 --- a/src/battle/effects.c +++ b/src/battle/effects.c @@ -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;