initial bar rendering
This commit is contained in:
parent
b0087c772a
commit
7160e10228
7 changed files with 79 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ set(RAYLIB_VERSION 5.5)
|
||||||
find_package(raylib ${RAYLIB_VERSION} REQUIRED)
|
find_package(raylib ${RAYLIB_VERSION} REQUIRED)
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
|
kubo_bar.c
|
||||||
kubo_wall.c
|
kubo_wall.c
|
||||||
kubo_window.c
|
kubo_window.c
|
||||||
kubo_context.c
|
kubo_context.c
|
||||||
|
|
|
||||||
28
kubo_bar.c
Normal file
28
kubo_bar.c
Normal file
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#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);
|
||||||
|
}
|
||||||
30
kubo_bar.h
Normal file
30
kubo_bar.h
Normal file
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef KUBO_BAR_H
|
||||||
|
#define KUBO_BAR_H
|
||||||
|
|
||||||
|
#define KUBO_BAR_HEIGHT 40
|
||||||
|
|
||||||
|
#include <raylib.h>
|
||||||
|
|
||||||
|
#include "kubo_context.h"
|
||||||
|
|
||||||
|
void kubo_bar_render(struct kubo_context *context);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -54,3 +54,7 @@ struct kubo_wall *kubo_context_get_pending_wall(struct kubo_context *context) {
|
||||||
|
|
||||||
return wall;
|
return wall;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *kubo_context_get_label(enum kubo_context_state state) {
|
||||||
|
return kubo_context_labels[state];
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,20 @@
|
||||||
|
|
||||||
KUBO_DYNARRAY_REGISTER(kubo_wall_arr, struct kubo_wall *);
|
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 {
|
struct kubo_context {
|
||||||
bool exit_pending;
|
bool exit_pending;
|
||||||
struct kubo_wall_arr walls;
|
struct kubo_wall_arr walls;
|
||||||
|
enum kubo_context_state state;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct kubo_context *kubo_context_init();
|
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);
|
struct kubo_wall *kubo_context_get_pending_wall(struct kubo_context *context);
|
||||||
|
|
||||||
|
const char *kubo_context_get_label(enum kubo_context_state state);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ void kubo_window_render(struct kubo_context *context) {
|
||||||
kubo_wall_render(wall);
|
kubo_wall_render(wall);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kubo_bar_render(context);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "kubo_context.h"
|
#include "kubo_context.h"
|
||||||
|
#include "kubo_bar.h"
|
||||||
|
|
||||||
#define KUBO_WINDOW_WIDTH 1000
|
#define KUBO_WINDOW_WIDTH 1000
|
||||||
#define KUBO_WINDOW_HEIGHT 800
|
#define KUBO_WINDOW_HEIGHT 800
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue