mirror of https://git.sr.ht/~kikoodx/sle
54 lines
967 B
C
54 lines
967 B
C
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
|
/* Copyright (C) 2021 KikooDX */
|
|
|
|
#include "conf.h"
|
|
#include "draw.h"
|
|
#include "level.h"
|
|
#include <assert.h>
|
|
#include <raylib.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
struct Level level;
|
|
level.data = NULL;
|
|
|
|
/* check for argument count */
|
|
if (argc != 3) {
|
|
fprintf(stderr, "ERROR: expected 2 arguments, got %d\n",
|
|
argc - 1);
|
|
return EXIT_FAILURE;
|
|
};
|
|
|
|
/* initialize raylib */
|
|
InitWindow(window_width, window_height, "SLE");
|
|
SetTargetFPS(target_fps);
|
|
/* load textures */
|
|
const Texture2D tileset = LoadTexture(argv[1]);
|
|
assert(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);
|
|
|
|
CloseWindow();
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|