From 03748610041bcc8ec7a7743e9a5fb35c06731fa0 Mon Sep 17 00:00:00 2001 From: UnavailableDev Date: Thu, 6 Apr 2023 17:31:38 +0200 Subject: printing strings coming to YOUR screen! --- src/demo.c | 2 +- src/engine/animator.c | 1 - src/game_loop/shop.c | 7 +++-- src/game_loop/shop.h | 2 +- src/game_loop/ui.c | 9 +++++-- src/game_loop/ui.h | 2 ++ src/static/.gitignore | 1 + src/static/dynamic.tsx | 71 +++++++++++++++++++++++++++++++++++++++++++++++--- 8 files changed, 84 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/demo.c b/src/demo.c index 20f8381..c8e3c0e 100644 --- a/src/demo.c +++ b/src/demo.c @@ -59,7 +59,7 @@ void hh_demo_loop(unsigned long frame) { } break; case hh_e_state_shop: - hh_shop(&hh_game_states, &hh_game.shop); + hh_shop(&hh_game_states, &hh_game.shop, hh_game.current_level); break; case hh_e_state_gameplay: hh_gameplay(&hh_game, &hh_game_states); diff --git a/src/engine/animator.c b/src/engine/animator.c index 71d0582..0811ba7 100644 --- a/src/engine/animator.c +++ b/src/engine/animator.c @@ -45,5 +45,4 @@ void hh_show_quad(uint16_t *idx, hh_s_rendering* in) { temp.position_y = CLAMP(in->fam.position_y, -16, HH_PPU_SCREEN_HEIGHT); temp.position_x = CLAMP(in->fam.position_x, -16, HH_PPU_SCREEN_WIDTH); hh_ppu_update_foreground(++*idx, temp); - temp.tilemap_index++; } diff --git a/src/game_loop/shop.c b/src/game_loop/shop.c index 60fc70b..ab2a1a0 100644 --- a/src/game_loop/shop.c +++ b/src/game_loop/shop.c @@ -4,7 +4,7 @@ #include "game_loop/ui.h" -void hh_shop(hh_e_game_state* hh_game_state, hh_level_entity* level_shop){ +void hh_shop(hh_e_game_state* hh_game_state, hh_level_entity* level_shop, int current_level){ static hh_e_shop_states hh_e_shop = hh_e_shop_show; static hh_e_upgrades upgrades[HH_SHOP_UPG_DISPLAY] = {0}; static uint8_t selected = 0; @@ -22,7 +22,10 @@ void hh_shop(hh_e_game_state* hh_game_state, hh_level_entity* level_shop){ selected = HH_SHOP_UPG_DISPLAY/2; hh_shop_display(selected, &upgrades); int idx = 16; - hh_ui_show_char(&idx,"aBYz09",(vec2){32,32}); + // hh_ui_show_char(&idx,"abyz09",(vec2){32,32}); + char* c[3]; + itoa(c,current_level); + hh_ui_show_char(&idx,c,(vec2){304-16-8,0}); hh_e_shop = hh_e_shop_main; break; diff --git a/src/game_loop/shop.h b/src/game_loop/shop.h index 6f8f5a7..cce0817 100644 --- a/src/game_loop/shop.h +++ b/src/game_loop/shop.h @@ -34,4 +34,4 @@ void hh_shop_display(uint8_t selected, hh_e_upgrades* upgrades); /** @brief moves 'cursor' through selection field */ void hh_shift_selected(uint8_t* pos, bool dir, uint8_t min, uint8_t max); -void hh_shop(hh_e_game_state* ,hh_level_entity* ); +void hh_shop(hh_e_game_state* ,hh_level_entity* , int); diff --git a/src/game_loop/ui.c b/src/game_loop/ui.c index 3354d43..8980d03 100644 --- a/src/game_loop/ui.c +++ b/src/game_loop/ui.c @@ -16,7 +16,6 @@ void hh_ui_show_hp(int* idx, hh_entity* player, uint8_t max_hp, vec_cor cam_pos) }); } } - void hh_ui_show_char(int* idx, char* str, vec2 pos) { int i = 0; int tilemap_idx, @@ -38,10 +37,16 @@ void hh_ui_show_char(int* idx, char* str, vec2 pos) { .horizontal_flip = false, .vertical_flip = false, .palette_index = palette_idx, .tilemap_index = tilemap_idx, - .position_x = 8 + i*15, .position_y = 8 + .position_x = pos.x + i*15, .position_y = pos.y } }); i++; } } + +void itoa(char *c, int i) { + c[0] = i + '0'; + c[1] = '\0'; +} + diff --git a/src/game_loop/ui.h b/src/game_loop/ui.h index 7a8ffbd..527cc74 100644 --- a/src/game_loop/ui.h +++ b/src/game_loop/ui.h @@ -17,3 +17,5 @@ void hh_ui_show_hp(int* idx, hh_entity* player, uint8_t max_hp, vec_cor cam_pos) void hh_ui_show_char(int* idx, char* str, vec2 pos); +/** @brief converts char* [0] to i and [1]='\0' */ +void itoa(char *c, int i); diff --git a/src/static/.gitignore b/src/static/.gitignore index e960c6e..4d628f9 100644 --- a/src/static/.gitignore +++ b/src/static/.gitignore @@ -7,3 +7,4 @@ tiled.mk *.csv *.out *.tiled-session +*.tmx diff --git a/src/static/dynamic.tsx b/src/static/dynamic.tsx index 742083f..fde4347 100644 --- a/src/static/dynamic.tsx +++ b/src/static/dynamic.tsx @@ -1,6 +1,9 @@ - + + + + @@ -103,9 +106,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -130,6 +175,27 @@ + + + + + + + + + + + + + + + + + + + + + @@ -322,7 +388,4 @@ - - - -- cgit v1.2.3