summaryrefslogtreecommitdiff
path: root/src/main.c
blob: 3710ae101511834bf35bd53a6f778c29b8407c02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "constants.h"
#include "raylib.h"
#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 s = StarCreate();
    stars[i] = &s;
  }

  while (!WindowShouldClose()) {
    BeginDrawing();
    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];
      star->position.z -= star->velocity;

      if (star->position.z < 1.0) {
        star->position = Generate3DPosition();
      }

      StarUpdate(star);

      DrawRectangle(star->renderPosition.x, star->renderPosition.y,
                    star->size.x, star->size.y, star->color);
    }

    EndDrawing();
  }

  return 0;
}