From 7160e10228490c2595fea8c43529461c167cb441 Mon Sep 17 00:00:00 2001 From: Luka Jankovic Date: Sat, 21 Jun 2025 19:33:12 +0200 Subject: [PATCH] initial bar rendering --- CMakeLists.txt | 1 + kubo_bar.c | 28 ++++++++++++++++++++++++++++ kubo_bar.h | 30 ++++++++++++++++++++++++++++++ kubo_context.c | 4 ++++ kubo_context.h | 13 +++++++++++++ kubo_window.c | 2 ++ kubo_window.h | 1 + 7 files changed, 79 insertions(+) create mode 100644 kubo_bar.c create mode 100644 kubo_bar.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ad37d90..c76bc4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ set(RAYLIB_VERSION 5.5) find_package(raylib ${RAYLIB_VERSION} REQUIRED) set(SOURCES + kubo_bar.c kubo_wall.c kubo_window.c kubo_context.c diff --git a/kubo_bar.c b/kubo_bar.c new file mode 100644 index 0000000..a1d1399 --- /dev/null +++ b/kubo_bar.c @@ -0,0 +1,28 @@ +/* + * Copyright Luka Jankovic 2025 + * + * This file is part of Kubo. + * + * Kubo is free software: you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * Kubo is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Kubo. If not, see . + */ + +#include "kubo_bar.h" + +void kubo_bar_render(struct kubo_context *context) { + + const int bar_y = GetScreenHeight() - KUBO_BAR_HEIGHT; + + DrawRectangle(0, bar_y, GetScreenWidth(), KUBO_BAR_HEIGHT, BLACK); + + DrawText(kubo_context_get_label(context->state), 0, bar_y, KUBO_BAR_HEIGHT, WHITE); +} diff --git a/kubo_bar.h b/kubo_bar.h new file mode 100644 index 0000000..0579d2a --- /dev/null +++ b/kubo_bar.h @@ -0,0 +1,30 @@ +/* + * Copyright Luka Jankovic 2025 + * + * This file is part of Kubo. + * + * Kubo is free software: you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * Kubo is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Kubo. If not, see . + */ + +#ifndef KUBO_BAR_H +#define KUBO_BAR_H + +#define KUBO_BAR_HEIGHT 40 + +#include + +#include "kubo_context.h" + +void kubo_bar_render(struct kubo_context *context); + +#endif diff --git a/kubo_context.c b/kubo_context.c index 58814f5..e30ba4d 100644 --- a/kubo_context.c +++ b/kubo_context.c @@ -54,3 +54,7 @@ struct kubo_wall *kubo_context_get_pending_wall(struct kubo_context *context) { return wall; } + +const char *kubo_context_get_label(enum kubo_context_state state) { + return kubo_context_labels[state]; +} diff --git a/kubo_context.h b/kubo_context.h index 1fbdb59..96e9ea0 100644 --- a/kubo_context.h +++ b/kubo_context.h @@ -28,9 +28,20 @@ KUBO_DYNARRAY_REGISTER(kubo_wall_arr, struct kubo_wall *); +enum kubo_context_state { + KUBO_CONTEXT_STATE_WALL_NEW, + KUBO_CONTEXT_STATE_WALL_SELECT, +}; + +static const char *kubo_context_labels[] = { + "Wall New", + "Wall Select" +}; + struct kubo_context { bool exit_pending; struct kubo_wall_arr walls; + enum kubo_context_state state; }; struct kubo_context *kubo_context_init(); @@ -38,4 +49,6 @@ void kubo_context_cleanup(struct kubo_context *context); struct kubo_wall *kubo_context_get_pending_wall(struct kubo_context *context); +const char *kubo_context_get_label(enum kubo_context_state state); + #endif diff --git a/kubo_window.c b/kubo_window.c index 273408b..8b79f77 100644 --- a/kubo_window.c +++ b/kubo_window.c @@ -45,6 +45,8 @@ void kubo_window_render(struct kubo_context *context) { kubo_wall_render(wall); } + kubo_bar_render(context); + EndDrawing(); } diff --git a/kubo_window.h b/kubo_window.h index 6b3f983..17bd4c2 100644 --- a/kubo_window.h +++ b/kubo_window.h @@ -23,6 +23,7 @@ #include #include "kubo_context.h" +#include "kubo_bar.h" #define KUBO_WINDOW_WIDTH 1000 #define KUBO_WINDOW_HEIGHT 800