summaryrefslogtreecommitdiff
path: root/src/main.c
blob: 9b79dcf7fb830da89a9a9a6cefc429853f5c32c1 (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
42
43
44
#include <stdlib.h>

#include "level.h"
#include "raylib.h"

int main() {
  SetConfigFlags(FLAG_WINDOW_RESIZABLE);
  InitWindow(800, 600, "sillyeditor");
  SetTargetFPS(60);

  int gridSize = 32;

  Level *level = SE_CreateLevel(30, 30);

  // creating a dummy side
  Side *side = malloc(sizeof(Side));
  side->a = (Point){1, 1};
  side->b = (Point){3, 4};
  level->sides[0] = side;

  while (!WindowShouldClose()) {
    BeginDrawing();
    ClearBackground(RAYWHITE);
    DrawText("hi world!", GetScreenWidth() / 2 - 16 * 4,
             GetScreenHeight() / 2 - 16, 32, BLACK);

    SE_RenderLevel(level, gridSize);

    // Drawing grid
    for (int x = 0; x <= level->width; x++) {
      DrawLine(x * gridSize, 0, x * gridSize, GetScreenHeight(), LIGHTGRAY);
    }

    for (int y = 0; y <= level->height; y++) {
      DrawLine(0, y * gridSize, GetScreenWidth(), y * gridSize, LIGHTGRAY);
    }

    EndDrawing();
  }

  SE_FreeLevel(level);

  return 0;
}