summaryrefslogtreecommitdiff
path: root/src/main.c
blob: 36ceb19c9a510c80d9b8d1908f922fbc9ff0db2b (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
45
46
47
48
49
50
#include <stddef.h>

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

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

  Level *level = SE_CreateLevel(30, 30);
  Editor editor = {level, {}};

  Camera2D camera = {0};
  camera.target = (Vector2){0.0f, 0.0f};
  camera.offset = (Vector2){0.0f, 0.0f};
  camera.rotation = 0.0f;
  camera.zoom = 4.0f;

  while (!WindowShouldClose()) {
    if (GetMouseWheelMove() != 0.0) {
      camera.zoom += (int)GetMouseWheelMove();

      if (camera.zoom > 6.0f)
        camera.zoom = 6.0f;
      else if (camera.zoom < 4.0f)
        camera.zoom = 4.0f;
    }

    if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) {
      Vector2 mousePos = GetMouseDelta();
      camera.target.x -= mousePos.x / 5.0f;
      camera.target.y -= mousePos.y / 5.0f;
    }

    BeginDrawing();
    ClearBackground(RAYWHITE);

    BeginMode2D(camera);
    SE_DrawEditor(&editor, &camera);
    EndMode2D();

    EndDrawing();
  }

  SE_FreeLevel(level);

  return 0;
}