diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-09-25 17:50:06 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-09-25 17:50:06 -0400 |
| commit | d6681412eeb19b49a308877a60c79e7b4b4c5303 (patch) | |
| tree | fbe3a518bc4bb50c5edcd117b33c0badaebe6fd5 /balls.h | |
| parent | 44dd6ad61dfed5d89f8abf7e8f41797501f071cc (diff) | |
| download | balls-d6681412eeb19b49a308877a60c79e7b4b4c5303.zip | |
variable radius
Diffstat (limited to 'balls.h')
| -rw-r--r-- | balls.h | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -4,10 +4,6 @@ #include <draw.h> #include <cursor.h> -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); |