summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
index 01678b9..3710ae1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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;
+ 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();