summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ball.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/ball.c b/src/ball.c
index 99415cc..2666a6e 100644
--- a/src/ball.c
+++ b/src/ball.c
@@ -112,6 +112,8 @@ void
db_balls_collisions(struct db_ball *ball)
{
struct db_map_line *line;
+ double prev_col_x;
+ double prev_col_y;
int line_x1;
int line_y1;
int line_x2;
@@ -122,6 +124,7 @@ db_balls_collisions(struct db_ball *ball)
/* Spinning balls shouldn't bounce off walls */
if (ball->sr == 0) {
+ prev_col_x = prev_col_y = -1;
for (line = db_map_get_lines(ball->map); line != NULL;
line = db_map_line_get_next(line)) {
db_map_line_get_coords(line, &line_x1, &line_y1,
@@ -131,8 +134,12 @@ db_balls_collisions(struct db_ball *ball)
line_x1, line_y1,
line_x2, line_y2,
&col_x, &col_y)){
+ if (col_x == prev_col_x || col_y == prev_col_y){
+ continue;
+ }
_db_ball_bounce(ball, col_x, col_y);
- break;
+ prev_col_x = col_x;
+ prev_col_y = col_y;
}
}
}