From 05860ed8ca92414281c803642aa74e2e1caa5b1c Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 24 Oct 2015 13:43:09 +0100 Subject: [PATCH] Tweaks to missile behaviour, to increase accuracy. --- src/battle/bullets.c | 13 +++++-------- src/battle/bullets.h | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/battle/bullets.c b/src/battle/bullets.c index 3b2b469..1f763bd 100644 --- a/src/battle/bullets.c +++ b/src/battle/bullets.c @@ -153,12 +153,9 @@ static void faceTarget(Bullet *b) b->angle = mod(b->angle, 360); - b->dx *= 0.35; - b->dy *= 0.35; - } - else - { - b->angle = wantedAngle; + /* halve your speed while you're not at the correct angle */ + b->dx *= 0.5; + b->dy *= 0.5; } } @@ -167,8 +164,8 @@ static void applyMissileThrust(Bullet *b) int maxSpeed; float v, thrust; - b->dx += sin(TO_RAIDANS(b->angle)) * 0.5; - b->dy += -cos(TO_RAIDANS(b->angle)) * 0.5; + b->dx += sin(TO_RAIDANS(b->angle)); + b->dy += -cos(TO_RAIDANS(b->angle)); maxSpeed = MAX(MIN(b->target->speed + 1, 999), 3); diff --git a/src/battle/bullets.h b/src/battle/bullets.h index 914c65d..818a651 100644 --- a/src/battle/bullets.h +++ b/src/battle/bullets.h @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../json/cJSON.h" #define TURN_SPEED 2 -#define TURN_THRESHOLD 8 +#define TURN_THRESHOLD 3 extern SDL_Texture *getTexture(char *filename); extern void blitRotated(SDL_Texture *texture, int x, int y, int angle);