From cf6f0f7038e7736f200f600c09f82ae350bc05b3 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 11 Dec 2024 13:12:28 +0500 Subject: upd: max and min for start pos z --- src/constants.h | 5 +++-- src/star.c | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/constants.h b/src/constants.h index 1edb712..3b9d446 100644 --- a/src/constants.h +++ b/src/constants.h @@ -1,6 +1,7 @@ #define STAR_AMOUNT 1000 -#define STAR_START_POS_Z 20.0 +#define STAR_START_POS_Z_MAX 20 +#define STAR_START_POS_Z_MIN 10 #define STAR_MIN_VELOCITY 1 -#define STAR_MAX_VELOCITY 25 +#define STAR_MAX_VELOCITY 5 #define SPACE_SIZE 35.0 diff --git a/src/star.c b/src/star.c index 4676a8f..822b9cf 100644 --- a/src/star.c +++ b/src/star.c @@ -18,7 +18,9 @@ Vector3 Generate3DPosition() { float x = radius * sin(angle); float y = radius * cos(angle); - Vector3 v = {x, y, STAR_START_POS_Z}; + Vector3 v = {x, y, + rand() % (STAR_START_POS_Z_MAX + 1 - STAR_START_POS_Z_MIN) + + STAR_START_POS_Z_MIN}; return v; } @@ -38,7 +40,8 @@ void StarUpdate(Star *star, float screen_center_x, float screen_center_y) { star->renderPosition.x = x; star->renderPosition.y = y; - float size = (STAR_START_POS_Z - star->position.z) / (0.2 * star->position.z); + float size = + (STAR_START_POS_Z_MAX - star->position.z) / (0.2 * star->position.z); star->size.x = size; star->size.y = size; -- cgit v1.2.3