summaryrefslogtreecommitdiff
path: root/src/star.c
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-12-10 21:49:41 +0500
committerilotterytea <iltsu@alright.party>2024-12-10 21:49:41 +0500
commita7d86efdb931a9587f0dffa1542569a562ce9a1b (patch)
treec739df329ecb7c04f2f2b8e74c582aed48b88a48 /src/star.c
parenta4acf6550319d307f318e69695838ce5d1abc263 (diff)
fix: stars were positioned in spiral
Diffstat (limited to 'src/star.c')
-rw-r--r--src/star.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/star.c b/src/star.c
index e8d2dfd..a0de9cc 100644
--- a/src/star.c
+++ b/src/star.c
@@ -7,11 +7,13 @@
#include "raylib.h"
Vector3 Generate3DPosition() {
- double random = (double)rand() / RAND_MAX;
+ double angle_random = (double)rand() / (double)RAND_MAX;
+ double radius_random = (double)rand() / (double)RAND_MAX;
- double angle = random * 2.0 * M_PI;
- double radius =
- (GetScreenHeight() / SPACE_SIZE) + (random * GetScreenHeight());
+ double angle = angle_random * 2.0 * M_PI;
+
+ double radius = (GetScreenHeight() / SPACE_SIZE) +
+ (radius_random * GetScreenHeight()) * SPACE_SIZE;
float x = radius * sin(angle);
float y = radius * cos(angle);