diff options
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 48 |
1 files changed, 23 insertions, 25 deletions
@@ -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; } |
