diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-09-25 20:41:49 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-09-25 20:41:49 -0400 |
| commit | a47f328277109dba8ca35a018c8c5f5641366362 (patch) | |
| tree | f5e1fe2d65507dcc22a64dc12ad4996484c3cbeb | |
| parent | 25b5660fbbd75378d465c5f70fd881cb10de4456 (diff) | |
| download | balls-a47f328277109dba8ca35a018c8c5f5641366362.zip | |
gravity
| -rw-r--r-- | balls.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -6,7 +6,7 @@ #define NELEMS(arr) (sizeof(arr) / sizeof(arr[0])) -#define G 0.25 +#define G 9.81 enum { BG = DWhite, @@ -20,6 +20,7 @@ enum { DEFAULT_NBALLS = 3, VMAX = 3, + MASS_FACTOR = 1, G_PER_KG = 1000, FPS = 60, @@ -279,7 +280,7 @@ maxelem(uint arr[], uint n) { double mass(uint radius) { - return (double) radius / 10 / G_PER_KG; + return (double) radius / MASS_FACTOR / G_PER_KG; } void @@ -302,7 +303,7 @@ ball(void *arg) { oldpos = b.p; for (;;) { - b.v.y += G; + b.v.y += b.m * G; b.p = ptaddv(b.p, b.v); |