summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-03-27 17:50:14 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-03-27 17:50:14 (EDT)
commit4a539a2210b90f4580adb46f9f8df7da2a391c29 (patch)
treebaf159359cda9569479b92824d33ab3cc05d09af
parent1af54624335128aa81ced4cd11c064a2188b296f (diff)
downloaddodge-balls-4a539a2210b90f4580adb46f9f8df7da2a391c29.zip
dodge-balls-4a539a2210b90f4580adb46f9f8df7da2a391c29.tar.gz
dodge-balls-4a539a2210b90f4580adb46f9f8df7da2a391c29.tar.bz2
ball: Keep angle in [0, 360)
-rw-r--r--src/ball.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/ball.c b/src/ball.c
index 767b565..14ee8de 100644
--- a/src/ball.c
+++ b/src/ball.c
@@ -87,7 +87,7 @@ db_balls_move(struct db_ball *ball)
ball->x += cos(ball->a * (M_PI / 180));
ball->y += sin(ball->a * (M_PI / 180));
} else {
- ball->a += ball->d * ball->s;
+ ball->a = fmod(ball->a + ball->d * ball->s, 360);
ball->x = ball->cx + cos(ball->a * (M_PI / 180)) * ball->sr;
ball->y = ball->cy + sin(ball->a * (M_PI / 180)) * ball->sr;
db_dbg("Spinning ball angle %f (speed %f, direction %d)",