mirror of https://git.sr.ht/~kikoodx/sle
parent
b487caeae3
commit
400e9d91f7
|
@ -12,6 +12,7 @@ set(SOURCES
|
|||
src/editing_area/level.c
|
||||
src/editing_area/draw.c
|
||||
src/tile_picker/main.c
|
||||
src/tile_picker/draw.c
|
||||
)
|
||||
|
||||
set(FLAGS
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
static const int game_window_width = 396;
|
||||
static const int game_window_height = 224;
|
||||
static const int picker_window_width = 256;
|
||||
static const int picker_window_height = 256;
|
||||
static const int draw_offset_x = -2;
|
||||
static const int draw_offset_y = -8;
|
||||
static const int tile_width = 16;
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
/* Copyright (C) 2021 KikooDX */
|
||||
#pragma once
|
||||
|
||||
#include <raylib.h>
|
||||
|
||||
void tileset_draw(Texture2D tileset);
|
|
@ -4,9 +4,7 @@
|
|||
#include "conf.h"
|
||||
#include "editing_area/draw.h"
|
||||
#include "editing_area/level.h"
|
||||
#include <assert.h>
|
||||
#include <raylib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int editing_area_main(int argc, char **argv)
|
||||
|
@ -14,40 +12,37 @@ int editing_area_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(game_window_width, game_window_height,
|
||||
"SLE main window");
|
||||
SetTargetFPS(target_fps);
|
||||
/* load textures */
|
||||
const Texture2D tileset = LoadTexture(argv[1]);
|
||||
assert(tileset.width > 0);
|
||||
|
||||
/* load level */
|
||||
level_read(&level, argv[2]);
|
||||
/* only process if tileset is well loaded */
|
||||
if (tileset.width > 0) {
|
||||
/* load level */
|
||||
level_read(&level, argv[2]);
|
||||
|
||||
while (!WindowShouldClose()) {
|
||||
/* draw */
|
||||
BeginDrawing();
|
||||
while (!WindowShouldClose()) {
|
||||
/* draw */
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(BLACK);
|
||||
level_draw(level, tileset);
|
||||
ClearBackground(BLACK);
|
||||
level_draw(level, tileset);
|
||||
|
||||
EndDrawing();
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
/* save level */
|
||||
level_write(level, argv[2]);
|
||||
}
|
||||
|
||||
/* save level */
|
||||
level_write(level, argv[2]);
|
||||
|
||||
/* deinit */
|
||||
level_free(&level);
|
||||
|
||||
/* unload textures */
|
||||
UnloadTexture(tileset);
|
||||
CloseWindow();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
|
10
src/main.c
10
src/main.c
|
@ -13,8 +13,16 @@
|
|||
* organize these panels in the way they want to. */
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
pid_t child_process = fork();
|
||||
pid_t child_process;
|
||||
|
||||
/* check for argument count */
|
||||
if (argc != 3) {
|
||||
fprintf(stderr, "ERROR: expected 2 arguments, got %d\n",
|
||||
argc - 1);
|
||||
return EXIT_FAILURE;
|
||||
};
|
||||
|
||||
child_process = fork();
|
||||
if (child_process < 0) {
|
||||
fprintf(stderr, "ERROR: process couldn't fork");
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
/* Copyright (C) 2021 KikooDX */
|
||||
|
||||
#include "tile_picker/draw.h"
|
||||
#include <raylib.h>
|
||||
|
||||
void tileset_draw(Texture2D tileset)
|
||||
{
|
||||
DrawTexture(tileset, 0, 0, WHITE);
|
||||
}
|
|
@ -1,12 +1,36 @@
|
|||
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
/* Copyright (C) 2021 KikooDX */
|
||||
|
||||
#include "editing_area/main.h"
|
||||
#include <stdio.h>
|
||||
#include "conf.h"
|
||||
#include "tile_picker/draw.h"
|
||||
#include <raylib.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int tile_picker_main(int argc, char **argv)
|
||||
{
|
||||
printf("hello you :)\n");
|
||||
/* initialize raylib */
|
||||
InitWindow(picker_window_width, picker_window_height,
|
||||
"SLE secondary window");
|
||||
SetTargetFPS(target_fps);
|
||||
/* load textures */
|
||||
const Texture2D tileset = LoadTexture(argv[1]);
|
||||
|
||||
/* only process if tileset is well loaded */
|
||||
if (tileset.width > 0) {
|
||||
while (!WindowShouldClose()) {
|
||||
/* draw */
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(BLACK);
|
||||
tileset_draw(tileset);
|
||||
|
||||
EndDrawing();
|
||||
}
|
||||
}
|
||||
|
||||
/* unload textures */
|
||||
UnloadTexture(tileset);
|
||||
CloseWindow();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue