aboutsummaryrefslogtreecommitdiff
path: root/src/game_loop/ui.c
diff options
context:
space:
mode:
authorUnavailableDev <ggwildplay@gmail.com>2023-04-06 16:40:34 +0200
committerUnavailableDev <ggwildplay@gmail.com>2023-04-06 16:40:34 +0200
commitd8e8e63bac3ef5a203106c09731ed2e55c87688a (patch)
treec9876a5c0f1cfea1eb56a2c046bcb4d5813e2d78 /src/game_loop/ui.c
parent93e9426d5642dfab7a13d5a34873b296de1d9642 (diff)
rendering hp + strings
Diffstat (limited to 'src/game_loop/ui.c')
-rw-r--r--src/game_loop/ui.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/game_loop/ui.c b/src/game_loop/ui.c
new file mode 100644
index 0000000..3354d43
--- /dev/null
+++ b/src/game_loop/ui.c
@@ -0,0 +1,47 @@
+#include "game_loop/ui.h"
+
+void hh_ui_show_hp(int* idx, hh_entity* player, uint8_t max_hp, vec_cor cam_pos) {
+ for (int i = 0; i < max_hp; i++) {
+ int tilemap_idx = HH_TM_HUD_HEART_OFFSET + (player->hp > i?0:1),
+ palette_idx = HH_PAL_IDX_HUD;
+ hh_show_quad(idx, &(hh_s_rendering){
+ .frame0 = tilemap_idx,
+ .palette = palette_idx,
+ .fam = (hh_s_ppu_loc_fam_entry){
+ .horizontal_flip = false, .vertical_flip = false,
+ .palette_index = palette_idx,
+ .tilemap_index = tilemap_idx,
+ .position_x = 8 + i*15, .position_y = 8
+ }
+ });
+ }
+}
+
+void hh_ui_show_char(int* idx, char* str, vec2 pos) {
+ int i = 0;
+ int tilemap_idx,
+ palette_idx = 6;
+ while (str[i] != '\0') {
+ if(str[i] >= 'A' && str[i] <= 'Z'){
+ tilemap_idx = HH_TM_FONT_OFFSET + str[i]-'A'+10;
+ } else if (str[i] >= 'a' && str[i] <= 'z') {
+ tilemap_idx = HH_TM_FONT_OFFSET + str[i]-'a'+10;
+ } else if (str[i] >= '0' && str[i] <= '9'){
+ tilemap_idx = HH_TM_FONT_OFFSET + str[i]-48;
+ } else {
+ return;
+ }
+ hh_show_quad(idx, &(hh_s_rendering){
+ .frame0 = tilemap_idx,
+ .palette = palette_idx,
+ .fam = (hh_s_ppu_loc_fam_entry){
+ .horizontal_flip = false, .vertical_flip = false,
+ .palette_index = palette_idx,
+ .tilemap_index = tilemap_idx,
+ .position_x = 8 + i*15, .position_y = 8
+ }
+ });
+ i++;
+ }
+
+}