better damage font
This commit is contained in:
parent
4c04a58f19
commit
de932ee339
|
@ -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)
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 276 B |
|
@ -1,6 +1,7 @@
|
|||
#include "particles.h"
|
||||
|
||||
#include <gint/display.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//---
|
||||
|
|
Loading…
Reference in New Issue