diff options
| author | ilotterytea <iltsu@alright.party> | 2024-12-10 19:50:26 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-12-10 19:50:26 +0500 |
| commit | c664ddaf47e078219b848b9e2d9c3c4241420261 (patch) | |
| tree | 0c30825531ecb5f4763d5fdc468a6128fafbe75e /src/main.c | |
| parent | 0a50b20f43c2abec41ba35c01f26ed5fa650e9f9 (diff) | |
feat: render stars!
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -3,17 +3,17 @@ #include "star.h" int main(int argc, char *argv[]) { + InitWindow(800, 600, "hyperspace (demo)"); + + SetTargetFPS(60); + Star *stars[STAR_AMOUNT] = {}; for (int i = 0; i < STAR_AMOUNT; i++) { - Star star = {{0, 0, 0}, {20, 20}, 1.0, BLACK}; - stars[i] = ☆ + Star s = StarCreate(); + stars[i] = &s; } - InitWindow(800, 600, "hyperspace (demo)"); - - SetTargetFPS(60); - while (!WindowShouldClose()) { BeginDrawing(); ClearBackground(WHITE); @@ -22,9 +22,16 @@ int main(int argc, char *argv[]) { for (int i = 0; i < sizeof(stars) / sizeof(stars[0]); i++) { Star *star = stars[i]; + star->position.z -= star->velocity; + + if (star->position.z < 1.0) { + star->position = Generate3DPosition(); + } + + StarUpdate(star); - DrawRectangle(star->position.x, star->position.y, star->size.x, - star->size.y, star->color); + DrawRectangle(star->renderPosition.x, star->renderPosition.y, + star->size.x, star->size.y, star->color); } EndDrawing(); |
