From b5bc4b9fdfd72a3f35b78c138836b963b0883d06 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 26 Mar 2021 22:53:47 -0400 Subject: ball: Move spinning balls --- (limited to 'src/ball.c') diff --git a/src/ball.c b/src/ball.c index 862efc4..1386cfd 100644 --- a/src/ball.c +++ b/src/ball.c @@ -77,6 +77,23 @@ db_ball_new(int x, int y, int r, int a, int d, int sr, double s, } void +db_balls_move(struct db_ball *ball) +{ + if (ball->sr == 0) { + } else { + ball->a += ball->d * ball->s; + 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)", + ball->a, ball->s, ball->d); + } + + if (ball->next != NULL) { + db_balls_move(ball->next); + } +} + +void db_balls_collisions(struct db_ball *ball) { struct db_ball *other; -- cgit v0.9.1