Tell missiles to turn more sharply when close to their target.
This commit is contained in:
parent
1913c844be
commit
9dd027b825
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue