diff --git a/src/battle/bullets.c b/src/battle/bullets.c index c36fa39..3b4e393 100644 --- a/src/battle/bullets.c +++ b/src/battle/bullets.c @@ -244,22 +244,34 @@ void drawBullets(void) static void faceTarget(Bullet *b) { - int dir; - int wantedAngle = getAngle(b->x, b->y, b->target->x, b->target->y); - - wantedAngle %= 360; + int dir, wantedAngle, dist; + + wantedAngle = (int)getAngle(b->x, b->y, b->target->x, b->target->y) % 360; if (fabs(wantedAngle - b->angle) > TURN_THRESHOLD) { dir = (wantedAngle - b->angle + 360) % 360 > 180 ? -1 : 1; b->angle += dir * TURN_SPEED; + + dist = getDistance(b->x, b->y, b->target->x, b->target->y); + + if (dist < 250) + { + dist = 250 - dist; + + while (dist > 0) + { + b->angle += dir; + + dist -= 50; + } + } b->angle = mod(b->angle, 360); - - /* lower your speed while you're not at the correct angle */ - b->dx *= 0.38; - b->dy *= 0.38; + + b->dx *= 0.75; + b->dy *= 0.75; } } diff --git a/src/battle/bullets.h b/src/battle/bullets.h index 2ea155f..cdc4900 100644 --- a/src/battle/bullets.h +++ b/src/battle/bullets.h @@ -45,6 +45,7 @@ extern char *getTranslatedString(char *string); 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 Battle battle; extern Colors colors;