summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-03-27 16:50:30 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-03-27 16:50:30 (EDT)
commit70ecfa6658fa50d9e9acb292e076c97a03154e50 (patch)
tree151d1adfe8842ecb68f9c8203d5b1265d8692183 /src
parent73d8c3a9db365cd19aa23afb2bc37879826780dd (diff)
downloaddodge-balls-70ecfa6658fa50d9e9acb292e076c97a03154e50.zip
dodge-balls-70ecfa6658fa50d9e9acb292e076c97a03154e50.tar.gz
dodge-balls-70ecfa6658fa50d9e9acb292e076c97a03154e50.tar.bz2
collision: s/int/double/ in circle-circle funcs
Diffstat (limited to 'src')
-rw-r--r--src/ball.c4
-rw-r--r--src/collision.c10
-rw-r--r--src/collision.h8
3 files changed, 11 insertions, 11 deletions
diff --git a/src/ball.c b/src/ball.c
index d7941b9..e37615b 100644
--- a/src/ball.c
+++ b/src/ball.c
@@ -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_ */