Skip to content

Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.

Kingdom Rush: the hero's box in the side bar while it is picked

Mason363735344171689
diff --git a/games/kingdomrush/src/hero.c b/games/kingdomrush/src/hero.c
index 301ba8f7..8dc676cc 100644
--- a/games/kingdomrush/src/hero.c
+++ b/games/kingdomrush/src/hero.c
@@ -1289,3 +1289,28 @@ void hero_draw_hud(bool selected) {
if (selected) gfx_frame_rect(ox - 1, oy - 1, 23, 26, RGB(0xFFE14D));
gfx_text_o(FONT_SMALL, ox + 23, oy, "4", RGB(0xFFE14D));
}
+
+/* the side bar's box while the hero is picked (the game's info panel: its name, life, level and respawn) */
+void hero_draw_info(void) {
+ Soldier *so = hero_soldier();
+ if (!so || gfx_y0 + BAND_H < 166) return;
+ gfx_fill(1, 166, 38, 74, RGB(0x1E140B));
+ gfx_fill(1, 166, 38, 1, RGB(0x8A6A3A));
+ int y = 168 + gfx_text_box(FONT_SMALL, 3, 168, 35, hero_name(H.id), RGB(0xF4E6C8));
+ char s[8], t[8];
+ int n = so->health > 0 ? so->health : 0, k = 0;
+ do t[k++] = (char)('0' + n % 10), n /= 10;
+ while (n && k < 7);
+ for (int i = 0; i < k; i++) s[i] = t[k - 1 - i];
+ s[k] = 0;
+ spr_anim(AN_UI_HEART, 0, false, 3, y + 1, false);
+ gfx_text(FONT_SMALL, 18, y, s, RGB(0xF4E6C8));
+ char l[8] = "Lvl 1";
+ if (H.level == 10) l[4] = '1', l[5] = '0', l[6] = 0;
+ else l[4] = (char)('0' + H.level);
+ gfx_text(FONT_SMALL, 3, y + 14, l, RGB(0x9A8A70));
+ char r[8] = "R 15s";
+ int sec = hs()->respawn / FPS;
+ r[2] = (char)('0' + sec / 10), r[3] = (char)('0' + sec % 10);
+ gfx_text(FONT_SMALL, 3, y + 25, r, RGB(0x9A8A70));
+}
diff --git a/games/kingdomrush/src/hero.h b/games/kingdomrush/src/hero.h
index 8c5f99b2..894f9fc0 100644
--- a/games/kingdomrush/src/hero.h
+++ b/games/kingdomrush/src/hero.h
@@ -30,6 +30,7 @@ void hero_bullet(Bullet *b);
void hero_draw_bullet(const Bullet *b, int x, int y);
void hero_draw_decals(void); /* mines, tar */
void hero_draw_hud(bool selected); /* the portrait, at the battlefield's top left */
+void hero_draw_info(void); /* its box in the side bar */
/* the player's orders */
Soldier *hero_soldier(void); /* the hero on the field (0: none yet) */
diff --git a/games/kingdomrush/src/play.c b/games/kingdomrush/src/play.c
index 6c2e0dc0..6c61d72d 100644
--- a/games/kingdomrush/src/play.c
+++ b/games/kingdomrush/src/play.c
@@ -616,7 +616,8 @@ static void draw_selection(void) {
static void draw_side(void) {
draw_sidebar(P.mode == M_AIM ? (P.aim == AIM_FIRE ? 1 : P.aim == AIM_REINF ? 2 : 0) : 0);
/* what is selected: an enemy's life and armour, a tower's numbers */
- if (P.mode == M_SELECT && P.sel_kind == SEL_ENEMY && EN(P.sel)) draw_enemy_info(EN(P.sel));
+ if (P.mode == M_AIM && P.aim == AIM_HERO) hero_draw_info();
+ else if (P.mode == M_SELECT && P.sel_kind == SEL_ENEMY && EN(P.sel)) draw_enemy_info(EN(P.sel));
else if (P.mode == M_SELECT && P.sel_kind == SEL_SPOT) draw_spot_info(&B.spot[P.sel]);
}