mirror of https://git.sr.ht/~kikoodx/sle
50 lines
949 B
C
50 lines
949 B
C
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
|
/* Copyright (C) 2021 KikooDX */
|
|
|
|
#include "conf.h"
|
|
#include "editing_area/draw.h"
|
|
#include "editing_area/level.h"
|
|
#include <raylib.h>
|
|
#include <stdlib.h>
|
|
|
|
int editing_area_main(int argc, char **argv)
|
|
{
|
|
struct Level level;
|
|
level.data = NULL;
|
|
|
|
/* initialize raylib */
|
|
InitWindow(game_window_width, game_window_height,
|
|
"SLE main window");
|
|
SetTargetFPS(target_fps);
|
|
/* load textures */
|
|
const Texture2D tileset = LoadTexture(argv[1]);
|
|
|
|
/* only process if tileset is well loaded */
|
|
if (tileset.width > 0) {
|
|
/* load level */
|
|
level_read(&level, argv[2]);
|
|
|
|
while (!WindowShouldClose()) {
|
|
/* draw */
|
|
BeginDrawing();
|
|
|
|
ClearBackground(BLACK);
|
|
level_draw(level, tileset);
|
|
|
|
EndDrawing();
|
|
}
|
|
|
|
/* save level */
|
|
level_write(level, argv[2]);
|
|
}
|
|
|
|
/* deinit */
|
|
level_free(&level);
|
|
|
|
/* unload textures */
|
|
UnloadTexture(tileset);
|
|
CloseWindow();
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|