summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-03-27 16:41:27 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-03-27 16:41:27 (EDT)
commit73d8c3a9db365cd19aa23afb2bc37879826780dd (patch)
tree4d2d2afaf7a9ca0ad79cd8936c1ab09bb950a1a0
parent30bb703ff3185f9c9c05cfbd67f0d008ea4c29bb (diff)
downloaddodge-balls-73d8c3a9db365cd19aa23afb2bc37879826780dd.zip
dodge-balls-73d8c3a9db365cd19aa23afb2bc37879826780dd.tar.gz
dodge-balls-73d8c3a9db365cd19aa23afb2bc37879826780dd.tar.bz2
ball: Don't collide spinning balls with others
-rw-r--r--src/ball.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/ball.c b/src/ball.c
index ccdccec..d7941b9 100644
--- a/src/ball.c
+++ b/src/ball.c
@@ -102,11 +102,15 @@ db_balls_collisions(struct db_ball *ball)
int col_x;
int col_y;
- for (other = ball->next; other != NULL; other = other->next) {
- if (db_col_pt_cir_cir(ball->x, ball->y, ball->r,
- other->x, other->y, other->r,
- &col_x, &col_y)) {
- /* TODO: Reverse direction */
+ /* Spinning balls shouldn't collide with any other balls */
+ if (ball->sr == 0) {
+ for (other = ball->next; other != NULL; other = other->next) {
+ if (other->sr == 0 && db_col_pt_cir_cir(
+ ball->x, ball->y, ball->r,
+ other->x, other->y, other->r,
+ &col_x, &col_y)) {
+ /* TODO: Reverse direction */
+ }
}
}