summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-12-10 21:56:43 +0500
committerilotterytea <iltsu@alright.party>2024-12-10 21:56:43 +0500
commitcbeb0314a90edb5ce28df2a8892160c0023320cb (patch)
treea1db4e616fac8f764357e24e812089bc75b68c94
parenta7d86efdb931a9587f0dffa1542569a562ce9a1b (diff)
feat: random velocity
-rw-r--r--src/constants.h3
-rw-r--r--src/star.c7
2 files changed, 9 insertions, 1 deletions
diff --git a/src/constants.h b/src/constants.h
index d1ca7f4..1edb712 100644
--- a/src/constants.h
+++ b/src/constants.h
@@ -1,3 +1,6 @@
#define STAR_AMOUNT 1000
#define STAR_START_POS_Z 20.0
+#define STAR_MIN_VELOCITY 1
+#define STAR_MAX_VELOCITY 25
+
#define SPACE_SIZE 35.0
diff --git a/src/star.c b/src/star.c
index a0de9cc..a92e63f 100644
--- a/src/star.c
+++ b/src/star.c
@@ -23,7 +23,12 @@ Vector3 Generate3DPosition() {
}
Star StarCreate() {
- return (Star){Generate3DPosition(), {1, 1}, {0, 0}, 0.25f, BLACK};
+ double velocity =
+ rand() % (STAR_MAX_VELOCITY + 1 - STAR_MIN_VELOCITY) + STAR_MIN_VELOCITY;
+
+ velocity /= 100.0;
+
+ return (Star){Generate3DPosition(), {1, 1}, {0, 0}, velocity, BLACK};
}
void StarUpdate(Star *star) {