summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-01-31 00:33:53 +0500
committerilotterytea <iltsu@alright.party>2025-01-31 00:33:53 +0500
commita15f24294d5113fec767fb9007d906f534dc0485 (patch)
tree20c869d1444a91256a10d4dfe0376f2f72ab4021 /src/main.c
parent2ca545f754acc9c8a00b5ce8c0b3ca1175c74a3a (diff)
upd: moved some editor logic to tileset and floor files
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/src/main.c b/src/main.c
index dd59a11..6c0e533 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3,9 +3,10 @@
#include <stdlib.h>
#include "editor.h"
+#include "floor.h"
#include "logger.h"
#include "raylib.h"
-#include "xd.h"
+#include "tileset.h"
int main() {
SetTraceLogCallback(SE_Logger);
@@ -15,29 +16,11 @@ int main() {
SetTargetFPS(60);
SetWindowMinSize(800, 600);
- // Getting list of files
- XdData* datas[] = {};
- FilePathList list = LoadDirectoryFilesEx("datas", ".xd", true);
+ Editor editor = {0};
+ editor.state.activeTileLayerId = 0;
- for (int i = 0; i < list.count; i++) {
- XdData data = Xd_LoadFromFile(list.paths[i]);
- printf("%s\n", data.name);
- datas[i] = &data;
- }
-
- UnloadDirectoryFiles(list);
-
- XdData* data = NULL;
- Editor editor = {data, {0, 0, 0, NULL, {0, 0, 0, 0}, {0, 0}, NULL, {}}};
-
- // creating a new xd data
- data = malloc(sizeof(XdData));
- editor.data = data;
- data->name = "xd";
- data->levels[0] = malloc(sizeof(XdLevel));
- data->levels[0]->floors[0] = malloc(sizeof(XdFloor));
- data->levels[0]->floors[0]->width = 30;
- data->levels[0]->floors[0]->height = 30;
+ Tileset* tileset = SE_CreateTileset();
+ TileFloor* floor = SE_CreateTileFloor(30, 30);
Camera2D camera = {0};
camera.target = (Vector2){0.0f, 0.0f};
@@ -47,6 +30,7 @@ int main() {
while (!WindowShouldClose()) {
SE_UpdateEditor(&editor);
+ SE_UpdateTileFloor(&editor.state, floor, &camera);
// interact with the map if the mouse is outside build tab
if (GetMousePosition().x < EDITOR_TOOLKIT_X) {
@@ -70,13 +54,27 @@ int main() {
ClearBackground(RAYWHITE);
BeginMode2D(camera);
- SE_DrawEditor(&editor, &camera);
+ SE_DrawTileFloor(floor, &editor.state, &camera);
+
+ // rendering grid
+ for (int x = 0; x < floor->width; x++) {
+ for (int y = 0; y < floor->height; y++) {
+ DrawRectangleLines(x * camera.zoom, y * camera.zoom,
+ TILE_WIDTH * camera.zoom, TILE_HEIGHT * camera.zoom,
+ BLACK);
+ }
+ }
+
EndMode2D();
- SE_DrawEditorToolkit(&editor);
+ SE_DrawEditor(&editor, tileset);
EndDrawing();
}
+ SE_UnloadTileFloor(floor);
+ SE_UnloadTileset(tileset);
+ CloseWindow();
+
return 0;
}