diff options
| author | ilotterytea <iltsu@alright.party> | 2025-01-18 21:22:32 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-01-18 21:22:32 +0500 |
| commit | 6c4ecd35da17e07b743d4ef75e234383317d22ac (patch) | |
| tree | 48e702ed1324f8526750d7dd90db464c2bb4742e /src/editor.c | |
| parent | f0284723a2e53b004777a71ad46cc4b75ed566ca (diff) | |
feat: new editor (wip) + using Camera2D
Diffstat (limited to 'src/editor.c')
| -rw-r--r-- | src/editor.c | 26 |
1 files changed, 26 insertions, 0 deletions
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); + } + } +} |
