From d6681412eeb19b49a308877a60c79e7b4b4c5303 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Wed, 25 Sep 2024 17:50:06 -0400 Subject: variable radius --- balls.h | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'balls.h') diff --git a/balls.h b/balls.h index 0e98506..7b68ea1 100644 --- a/balls.h +++ b/balls.h @@ -4,10 +4,6 @@ #include #include -enum { - RADIUS = 20, -}; - typedef struct { double x, y; } Vec; @@ -17,9 +13,10 @@ typedef struct { } Line; typedef struct { - Point p; /* position */ - Vec v; /* velocity */ - double m; /* mass */ + Point p; /* position [pixels] */ + Vec v; /* velocity [m/s] */ + uint r; /* radius [pixels] */ + double m; /* mass [kg] */ } Ball; Vec vsub(Vec v1, Vec v2); @@ -33,9 +30,9 @@ Vec V(double x, double y); Vec Vpt(Point p, Point q); void drawbg(Image *walls, Image *bg); -Image *alloccircle(int fg, int bg); +Image *alloccircle(int fg, int bg, uint radius); void drawcircle(Image *m, Point pos); -int iscollision(Point p, Point q); +int iscollision(Point p1, uint r1, Point p2, uint r2); void collideball(Ball *b1, const Ball *b2); void collidewall(Ball *b, Rectangle wall); -- cgit v1.2.3