diff --git a/CMakeLists.txt b/CMakeLists.txt index 48c7285..12477c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,8 @@ set(ASSETS # Enemies: Bat assets-cg/enemies/bat_idle_down.png assets-cg/enemies/bat_death.png + # Misc + assets-cg/font_damage.png ) fxconv_declare_assets(${ASSETS} ${ASSETS} WITH_METADATA) diff --git a/assets-cg/font_damage.png b/assets-cg/font_damage.png new file mode 100644 index 0000000..5b0236b Binary files /dev/null and b/assets-cg/font_damage.png differ diff --git a/src/particles.c b/src/particles.c index ad9da41..70942b0 100644 --- a/src/particles.c +++ b/src/particles.c @@ -1,6 +1,7 @@ #include "particles.h" #include +#include static bool damage_update(particle_damage_t *p, GUNUSED fixed_t dt) { @@ -9,8 +10,23 @@ static bool damage_update(particle_damage_t *p, GUNUSED fixed_t dt) static void damage_render(int x, int y, particle_damage_t *p) { - dprint_opt(x, y, C_WHITE, C_NONE, DTEXT_CENTER, DTEXT_MIDDLE, "%d", - p->damage); + extern bopti_image_t img_font_damage; + int char_w = img_font_damage.width / 10; + int char_h = img_font_damage.height; + + /* Determine number of characters */ + char str[16]; + int n = snprintf(str, 16, "%d", p->damage); + + y -= char_h / 2; + x -= (char_w * n + 1) / 2; + + for(int i = 0; i < n; i++) { + int offset = (char_w + 1) * (str[i] - '0'); + dsubimage(x, y, &img_font_damage, offset, 0, char_w, char_h, + DIMAGE_NONE); + x += char_w; + } } //---