From d74071a33966522def001d280d19f99138b18e06 Mon Sep 17 00:00:00 2001 From: Antonio Carzaniga Date: Wed, 5 Jun 2019 14:51:02 +0200 Subject: [PATCH] allowing initial velocity in all directions --- balls.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/balls.c b/balls.c index 3e37afb..8b154d3 100644 --- a/balls.c +++ b/balls.c @@ -50,6 +50,10 @@ void balls_init_state () { balls[i].y = border + rand() % h; balls[i].v_x = v_min + rand() % (v_max + 1 - v_min); balls[i].v_y = v_min + rand() % (v_max + 1 - v_min); + if (rand() % 2) + balls[i].v_x = -balls[i].v_x; + if (rand() % 2) + balls[i].v_y = -balls[i].v_y; balls[i].radius = radius_min + rand() % (radius_max + 1 - radius_min); balls[i].rgb_channels[0] = rand() % 256; balls[i].rgb_channels[1] = rand() % 256;