diff options
author | quou <quou@disroot.org> | 2024-10-01 23:01:12 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-10-01 23:01:12 +1000 |
commit | 5331a6aafbbd03d53918b53565b81dac14ec30ca (patch) | |
tree | bfc6e002c9183ff848d13bb214f85bf0a2bda884 | |
parent | c474a43f800c7e7a0a90adcc997ba4e30dd2ae56 (diff) |
draw the current special on the hud
-rw-r--r-- | hud.c | 36 |
1 files changed, 35 insertions, 1 deletions
@@ -3,12 +3,19 @@ #include "render.h" #include "world.h" +const int specials_pos[][2] = { +#define x(name, x, y) { x, y }, + specials_xmacro +#undef x +}; + const Rect heart_empty_rect = { 0, 0, 7, 6 }; const Rect heart_half_rect = { 7, 0, 7, 6 }; const Rect heart_full_rect = { 14, 0, 7, 6 }; const Rect charge_empty_rect = { 0, 6, 7, 7 }; const Rect charge_full_rect = { 7, 6, 7, 7 }; -const Rect background_rect = { 0, 13, 37, 20 }; +const Rect background_rect = { 0, 13, 37, 29 }; +const int special_size[2] = { 16, 8 }; const int hud_offset_x = 4; const int hud_offset_y = 4; @@ -110,15 +117,42 @@ void hud_charge(Renderer* r, const Bitmap* bm, int c, int f) { } } +void hud_special(Renderer* r, const Bitmap* bm, Special s) { + const int y = + hud_offset_y + + heart_empty_rect.h + + charge_empty_rect.h + + 5; + int x; + Rect rect; + rect.x = specials_pos[s][0]; + rect.y = specials_pos[s][1]; + rect.w = special_size[0]; + rect.h = special_size[1]; + x = + hud_offset_x + + (background_rect.w >> 1) - + (special_size[0] >> 1); + ren_map( + r, + x, + y, + &rect, + bm + ); +} + void ren_hud(const World* w, Renderer* r) { const Bitmap* bm = get_bitmap(asset_id_hud_img); const Player* p = &w->player; const int hp = p->hp; const int c = p->charge; + const Special s = p->spec; hud_clip(r); ren_clear(r); hud_background(r, bm); hud_hp(r, bm, hp); hud_charge(r, bm, c, w->frame); + hud_special(r, bm, s); ren_rclip(r); } |