diff options
-rw-r--r-- | src/ball.c | 4 | ||||
-rw-r--r-- | src/collision.c | 10 | ||||
-rw-r--r-- | src/collision.h | 8 |
3 files changed, 11 insertions, 11 deletions
@@ -99,8 +99,8 @@ void db_balls_collisions(struct db_ball *ball) { struct db_ball *other; - int col_x; - int col_y; + double col_x; + double col_y; /* Spinning balls shouldn't collide with any other balls */ if (ball->sr == 0) { diff --git a/src/collision.c b/src/collision.c index e17e78a..45462e5 100644 --- a/src/collision.c +++ b/src/collision.c @@ -64,7 +64,7 @@ db_col_cir_rect(int x, int y, int r, SDL_Rect *rect, int *col_x, int *col_y) } int -db_col_cir_cir(int x1, int y1, int r1, int x2, int y2, int r2) +db_col_cir_cir(double x1, double y1, double r1, double x2, double y2, double r2) { return ((r1 + r2) * (r1 + r2)) >= ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); @@ -76,12 +76,12 @@ db_col_cir_cir(int x1, int y1, int r1, int x2, int y2, int r2) * movements to find the exact point of collision. */ int -db_col_pt_cir_cir(int x1, int y1, int r1, int x2, int y2, int r2, - int *col_x, int *col_y) +db_col_pt_cir_cir(double x1, double y1, double r1, + double x2, double y2, double r2, double *col_x, double *col_y) { if (db_col_cir_cir(x1, y1, r1, x2, y2, r2)) { - *col_x = (x1 + x2) / 2; - *col_y = (y1 + y2) / 2; + *col_x = (x1 + x2) / 2.0; + *col_y = (y1 + y2) / 2.0; return 1; } else { return 0; diff --git a/src/collision.h b/src/collision.h index 896620b..02d93e3 100644 --- a/src/collision.h +++ b/src/collision.h @@ -27,9 +27,9 @@ void db_closest_pt_on_rect(int x, int y, SDL_Rect *rect, int *close_x, int *close_y); int db_col_cir_rect(int x, int y, int r, SDL_Rect *rect, int *col_x, int *col_y); -int db_col_cir_cir(int x1, int y1, int r1, int x2, int y2, int r2) - __attribute__((__const__)); -int db_col_pt_cir_cir(int x1, int y1, int r1, int x2, int y2, int r2, - int *col_x, int *col_y); +int db_col_cir_cir(double x1, double y1, double r1, + double x2, double y2, double r2) __attribute__((__const__)); +int db_col_pt_cir_cir(double x1, double y1, double r1, + double x2, double y2, double r2, double *col_x, double *col_y); #endif /* DB_COLLISION_H_ */ |