From 6c4ecd35da17e07b743d4ef75e234383317d22ac Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 18 Jan 2025 21:22:32 +0500 Subject: feat: new editor (wip) + using Camera2D --- src/editor.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/editor.c (limited to 'src/editor.c') diff --git a/src/editor.c b/src/editor.c new file mode 100644 index 0000000..64f1673 --- /dev/null +++ b/src/editor.c @@ -0,0 +1,26 @@ +#include "editor.h" + +#include "raylib.h" + +void SE_DrawEditor(Editor *editor, Camera2D *camera) { + Vector2 mousePos = GetScreenToWorld2D(GetMousePosition(), *camera); + float zoom = camera->zoom; + + for (int x = 0; x < editor->level->width; x++) { + for (int y = 0; y < editor->level->height; y++) { + float rx = x * zoom, ry = y * zoom; + Color innerColor = RAYWHITE; + Color borderColor = LIGHTGRAY; + + // recolor the tile if the cursor above the tile + if ((rx < mousePos.x && mousePos.x < rx + zoom) && + (ry < mousePos.y && mousePos.y < ry + zoom)) { + innerColor = SKYBLUE; + borderColor = BLUE; + } + + DrawRectangle(rx, ry, zoom, zoom, innerColor); + DrawRectangleLines(rx, ry, zoom, zoom, borderColor); + } + } +} -- cgit v1.2.3