From 0a50b20f43c2abec41ba35c01f26ed5fa650e9f9 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 10 Dec 2024 17:24:57 +0500 Subject: feat: init stars --- src/constants.h | 1 + src/main.c | 17 +++++++++++++++++ src/star.h | 8 ++++++++ 3 files changed, 26 insertions(+) create mode 100644 src/constants.h create mode 100644 src/star.h diff --git a/src/constants.h b/src/constants.h new file mode 100644 index 0000000..ecd5b1f --- /dev/null +++ b/src/constants.h @@ -0,0 +1 @@ +#define STAR_AMOUNT 1000 diff --git a/src/main.c b/src/main.c index 7c5fcbf..01678b9 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,15 @@ +#include "constants.h" #include "raylib.h" +#include "star.h" int main(int argc, char *argv[]) { + Star *stars[STAR_AMOUNT] = {}; + + for (int i = 0; i < STAR_AMOUNT; i++) { + Star star = {{0, 0, 0}, {20, 20}, 1.0, BLACK}; + stars[i] = ☆ + } + InitWindow(800, 600, "hyperspace (demo)"); SetTargetFPS(60); @@ -10,6 +19,14 @@ int main(int argc, char *argv[]) { ClearBackground(WHITE); DrawText("hi world!", GetScreenWidth() / 2.0 - 16 * 4, GetScreenHeight() / 2.0 - 16, 32, BLACK); + + for (int i = 0; i < sizeof(stars) / sizeof(stars[0]); i++) { + Star *star = stars[i]; + + DrawRectangle(star->position.x, star->position.y, star->size.x, + star->size.y, star->color); + } + EndDrawing(); } diff --git a/src/star.h b/src/star.h new file mode 100644 index 0000000..bc215ee --- /dev/null +++ b/src/star.h @@ -0,0 +1,8 @@ +#include "raylib.h" + +typedef struct Star { + Vector3 position; + Vector2 size; + float velocity; + Color color; +} Star; -- cgit v1.2.3