summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-09-25 20:41:49 -0400
committerSam Anthony <sam@samanthony.xyz>2024-09-25 20:41:49 -0400
commita47f328277109dba8ca35a018c8c5f5641366362 (patch)
treef5e1fe2d65507dcc22a64dc12ad4996484c3cbeb
parent25b5660fbbd75378d465c5f70fd881cb10de4456 (diff)
downloadballs-a47f328277109dba8ca35a018c8c5f5641366362.zip
gravity
-rw-r--r--balls.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/balls.c b/balls.c
index 6717e60..77efa2d 100644
--- a/balls.c
+++ b/balls.c
@@ -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);