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 map's road and star board, full stories, pictures in the notes

Mason363fff9a6dcf715
diff --git a/games/kingdomrush/src/data.bin b/games/kingdomrush/src/data.bin
index d1d8a87c..8efb6079 100644
Binary files a/games/kingdomrush/src/data.bin and b/games/kingdomrush/src/data.bin differ
diff --git a/games/kingdomrush/src/data.h b/games/kingdomrush/src/data.h
index 56154adb..4b97812f 100644
--- a/games/kingdomrush/src/data.h
+++ b/games/kingdomrush/src/data.h
@@ -545,23 +545,26 @@
#define AN_UI_FLAGSEL 508
#define AN_UI_FLAGSTAR 509
#define AN_UI_FLAGHEROIC 510
-#define AN_UI_UPICONS 511
-#define AN_UI_UPITEM 512
-#define AN_T_BASE_ENG_FOREST 513
-#define AN_T_BASE_ENG_SNOW 514
-#define AN_T_BASE_ENG_WASTELAND 515
-#define AN_T_BASE_BFG_FOREST 516
-#define AN_T_BASE_BFG_SNOW 517
-#define AN_T_BASE_BFG_WASTELAND 518
-#define AN_T_BASE_TESLA_FOREST 519
-#define AN_T_BASE_TESLA_SNOW 520
-#define AN_T_BASE_TESLA_WASTELAND 521
-#define AN_T_BASE_RANGER_FOREST 522
-#define AN_T_BASE_RANGER_SNOW 523
-#define AN_T_BASE_RANGER_WASTELAND 524
-#define AN_T_BASE_MUSKETEER_FOREST 525
-#define AN_T_BASE_MUSKETEER_SNOW 526
-#define AN_T_BASE_MUSKETEER_WASTELAND 527
+#define AN_UI_ROAD 511
+#define AN_UI_STAR 512
+#define AN_UI_STARBOARD 513
+#define AN_UI_UPICONS 514
+#define AN_UI_UPITEM 515
+#define AN_T_BASE_ENG_FOREST 516
+#define AN_T_BASE_ENG_SNOW 517
+#define AN_T_BASE_ENG_WASTELAND 518
+#define AN_T_BASE_BFG_FOREST 519
+#define AN_T_BASE_BFG_SNOW 520
+#define AN_T_BASE_BFG_WASTELAND 521
+#define AN_T_BASE_TESLA_FOREST 522
+#define AN_T_BASE_TESLA_SNOW 523
+#define AN_T_BASE_TESLA_WASTELAND 524
+#define AN_T_BASE_RANGER_FOREST 525
+#define AN_T_BASE_RANGER_SNOW 526
+#define AN_T_BASE_RANGER_WASTELAND 527
+#define AN_T_BASE_MUSKETEER_FOREST 528
+#define AN_T_BASE_MUSKETEER_SNOW 529
+#define AN_T_BASE_MUSKETEER_WASTELAND 530
#define EN_GOBLIN 0
#define EN_FATORC 1
#define EN_WOLFSMALL 2
diff --git a/games/kingdomrush/src/enemy.c b/games/kingdomrush/src/enemy.c
index 5899bc8d..c8d36b6b 100644
--- a/games/kingdomrush/src/enemy.c
+++ b/games/kingdomrush/src/enemy.c
@@ -597,7 +597,7 @@ void enemy_step(Enemy *e) {
if (e->dead) return;
debuffs(e);
if (e->dead || !e->alive) return;
- if (e->rage_t > 0 && e->type != EN_NECROMANCER && --e->rage_t == 0) { /* the chieftain's rage ends */
+ if (e->rage_t > 0 && (e->type == EN_TROLL || e->type == EN_TROLLAXETHROWER || e->type == EN_TROLLCHIEFTAIN) && --e->rage_t == 0) { /* the chieftain's rage ends */
e->min_dmg = (int16_t)(e->min_dmg - S_enemies_trollChieftain_rageAddedMinDamage);
e->max_dmg = (int16_t)(e->max_dmg - S_enemies_trollChieftain_rageAddedMaxDamage);
e->speed -= S_enemies_trollChieftain_rageAddedSpeed, e->base_speed -= S_enemies_trollChieftain_rageAddedSpeed;
diff --git a/games/kingdomrush/src/menus.c b/games/kingdomrush/src/menus.c
index f0179bf3..40fab02b 100644
--- a/games/kingdomrush/src/menus.c
+++ b/games/kingdomrush/src/menus.c
@@ -105,6 +105,11 @@ void map_step(void) {
static void map_band(void) {
pic_draw(PIC_MAP, 0, 0);
+ /* the road so far: to the stage after the last one won */
+ int won = 0;
+ while (won < NLEVELS && g.p.camp[won]) won++;
+ if (won > 11) won = 11;
+ if (won) spr_anim(AN_UI_ROAD, won - 1, false, 0, -MAP_Y0, false);
for (int i = 0; i < NLEVELS; i++) {
if (!unlocked(i)) continue;
int x = fx(i), y = fy(i);
@@ -120,43 +125,40 @@ static void map_band(void) {
spr_anim(AN_UI_FLAGNEW, 0, false, x, y, false);
}
/* the stars: won, and free to spend */
- if (gfx_rows(2, 18)) {
- gfx_panel(2, 2, 74, 17, RGB(0x2A1A0C), RGB(0xC09A5A));
+ if (gfx_rows(0, 30)) { /* MapStarProgress: the stars won */
+ spr_anim(AN_UI_STARBOARD, 0, false, 248, 0, false);
char s[24];
snprintf(s, sizeof s, "%d/%d", stars_won(), stars_max());
- spr_anim(AN_UI_FLAGSTAR, 1, false, 5, 4, false);
- gfx_text(FONT_HUD, 22, 3, s, C_GOLD);
+ gfx_text_oc(FONT_HUD, 278, 6, s, WHITE);
}
if (!win_open) {
char s[64];
- snprintf(s, sizeof s, "Arrows choose OK play %s 0 upgrades (%d stars)", level_title(g.map_sel), stars_free());
+ snprintf(s, sizeof s, "OK play %s 0 upgrades", level_title(g.map_sel));
key_line(s);
return;
}
/* LevelSelect: the stage's title, its story, its three modes */
int i = g.map_sel;
- if (!gfx_rows(30, 180)) return;
- panel(30, 30, 260, 176);
- gfx_text_oc(FONT_BIG, 160, 36, level_title(i), C_GOLD);
- char story[200];
- snprintf(story, sizeof story, "%s", level_story(i));
- if (strlen(story) > 180) strcpy(story + 176, "...");
- gfx_text_box(FONT_TEXT, 42, 64, 236, story, C_TEXT);
- static const char *const names[3] = {"Campaign", "Heroic", "Iron"};
- for (int m = 0; m < 3; m++) {
- int x = 75 + 85 * m, y = 150;
- bool open = mode_open(i, m), sel = m == win_mode;
- gfx_panel(x - 36, y, 72, 20, sel ? RGB(0xE0A020) : RGB(0x5A3E20), sel ? WHITE : RGB(0xC09A5A));
- gfx_text_c(FONT_HUD, x, y + 3, names[m], !open ? C_DIM : sel ? RGB(0x2A1A0C) : C_TEXT);
- bool done = m == 0 ? g.p.camp[i] > 0 : m == 1 ? g.p.heroic[i] : g.p.iron[i];
- if (done) spr_anim(AN_UI_FLAGSTAR, 1, false, x + 26, y - 6, false);
+ if (gfx_rows(4, 220)) {
+ panel(4, 4, 312, 220);
+ gfx_text_oc(FONT_BIG, 160, 8, level_title(i), C_GOLD);
+ gfx_text_box(FONT_TEXT, 16, 36, 290, level_story(i), C_TEXT);
+ static const char *const names[3] = {"Campaign", "Heroic", "Iron"};
+ for (int m = 0; m < 3; m++) {
+ int x = 75 + 85 * m, y = 180;
+ bool open = mode_open(i, m), sel = m == win_mode;
+ gfx_panel(x - 36, y, 72, 20, sel ? RGB(0xE0A020) : RGB(0x5A3E20), sel ? WHITE : RGB(0xC09A5A));
+ gfx_text_c(FONT_HUD, x, y + 3, names[m], !open ? C_DIM : sel ? RGB(0x2A1A0C) : C_TEXT);
+ bool done = m == 0 ? g.p.camp[i] > 0 : m == 1 ? g.p.heroic[i] : g.p.iron[i];
+ if (done) spr_anim(AN_UI_STAR, 0, false, x + 24, y - 8, false);
+ }
+ const char *rule = win_mode == 0 ? "Lose a life for each enemy that gets through."
+ : !mode_open(i, win_mode) ? "Win this stage with 3 stars to open it."
+ : win_mode == 1 ? "6 elite waves, 1 life, upgrades capped."
+ : "1 big wave, 1 life, some towers barred.";
+ gfx_text_c(FONT_SMALL, 160, 206, rule, C_DIM);
}
- const char *rule = win_mode == 0 ? "Defend the realm. Lose a life for each enemy that gets through."
- : !mode_open(i, win_mode) ? "Win this stage with 3 stars to open it."
- : win_mode == 1 ? "6 elite waves, 1 life, upgrades capped."
- : "1 big wave, 1 life, some towers barred.";
- gfx_text_c(FONT_SMALL, 160, 176, rule, C_DIM);
- gfx_text_c(FONT_SMALL, 160, 190, "Left Right mode OK fight Back close", C_TEXT);
+ key_line("Left Right mode OK fight Back close");
}
void map_draw(void) { gfx_frame(map_band); }
@@ -232,7 +234,7 @@ static void upgrades_band(void) {
/* stars to spend, and what the chosen one does */
char s[48];
snprintf(s, sizeof s, "%d", stars_free());
- spr_anim(AN_UI_FLAGSTAR, 1, false, UPG_X + 8, 214, false);
+ spr_anim(AN_UI_STAR, 0, false, UPG_X + 8, 213, false);
gfx_text_o(FONT_HUD, UPG_X + 25, 213, s, C_GOLD);
if (gfx_rows(0, 240)) {
const char *nm = upgrade_name(up_col, up_row), *ds = upgrade_desc(up_col, up_row);
diff --git a/games/kingdomrush/src/strings.c b/games/kingdomrush/src/strings.c
index 6b4cb9ac..ed01fe5d 100644
--- a/games/kingdomrush/src/strings.c
+++ b/games/kingdomrush/src/strings.c
@@ -46,6 +46,12 @@ static const char *const notes[][2] = {
{"New enemy: Demon Imp", "Flying mischievious infernal creatures that are often seen in the company of gargoyles.. Flying."},
{"New enemy: Necromancer", "Master of the dark arts, the Necromancer summons undead minions to do their bidding. Summons undead, Ranged attack."},
};
+static const uint8_t note_pics[][2] = {{0, 0}, {2, 2}, {2, 1}, {1, 0}, {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {1, 2}, {1, 3}, {0, 0}, {1, 4}, {0, 0}, {1, 5}, {1, 6}, {1, 10}, {3, TW_RANGER}, {1, 8}, {1, 9}, {1, 7}, {3, TW_ARCANE}, {0, 0}, {1, 13}, {1, 14}, {1, 12}, {3, TW_MUSKETEER}, {1, 18}, {1, 17}, {3, TW_BARBARIAN}, {1, 20}, {1, 21}, {1, 19}, {3, TW_SORCERER}, {1, 23}, {1, 24}, {3, TW_TESLA}, {1, 28}, {1, 29}, {1, 27}, {1, 31}, {1, 30}};
+int note_pic(int n, int *arg) {
+ if (n <= 0 || n >= (int)(sizeof note_pics / sizeof note_pics[0])) return 0;
+ *arg = note_pics[n][1];
+ return note_pics[n][0];
+}
const char *note_title(int n) { return n > 0 && n < (int)(sizeof notes / sizeof notes[0]) ? notes[n][0] : 0; }
const char *note_text(int n) { return n > 0 && n < (int)(sizeof notes / sizeof notes[0]) && notes[n][1][0] ? notes[n][1] : 0; }
diff --git a/games/kingdomrush/src/strings.h b/games/kingdomrush/src/strings.h
index e2ba4194..c2c60ab5 100644
--- a/games/kingdomrush/src/strings.h
+++ b/games/kingdomrush/src/strings.h
@@ -3,6 +3,7 @@
#define KR_STRINGS_H
const char *note_title(int n);
const char *note_text(int n); /* 0 when there is nothing to show */
+int note_pic(int n, int *arg); /* 1 an enemy, 2 a spell, 3 a tower (TW_*), 0 none */
const char *enemy_desc(int type);
const char *level_title(int i);
const char *level_story(int i);
diff --git a/games/kingdomrush/src/ui.c b/games/kingdomrush/src/ui.c
index 2176586a..35a5f430 100644
--- a/games/kingdomrush/src/ui.c
+++ b/games/kingdomrush/src/ui.c
@@ -3,6 +3,8 @@
#include <math.h>
#include <stdio.h>
#include <string.h>
+#include "anim.h"
+#include "game.h"
#include "gfx.h"
#include "settings.h"
#include "special.h"
@@ -109,12 +111,13 @@ void draw_ring(const RingItem *it, int n, int sel, int cx, int cy, int cash) {
int slot = anim_slot(AN_UI_ICONS, it[i].icon - 1, false);
bool afford = it[i].action == RA_SELL || it[i].action == RA_RALLY || it[i].cost <= cash;
bool done = it[i].max && it[i].level >= it[i].max;
- if (i == sel) {
- gfx_ellipse_fill(x, y, 11, 11, RGB(0xFFE14D), 32);
- gfx_ellipse(x, y, 12, 12, RGB(0x6A4A00), 32);
+ if (it[i].locked || !afford || done) spr_frame_tint(slot, x, y, false, RGB(0x302820), 18);
+ else spr_frame(slot, x, y, false);
+ if (i == sel) { /* the chosen one: a bright ring */
+ gfx_ellipse(x, y, 11, 11, RGB(0xFFE14D), 32);
+ gfx_ellipse(x, y, 12, 12, RGB(0xFFE14D), 32);
+ gfx_ellipse(x, y, 13, 13, RGB(0x4A3000), 32);
}
- if (it[i].locked || !afford || done) spr_frame_tint(slot, x - 10, y - 10, false, RGB(0x302820), 18);
- else spr_frame(slot, x - 10, y - 10, false);
if (it[i].cost && !it[i].locked && !done) {
char s[8];
snprintf(s, sizeof s, "%d", it[i].cost);
@@ -404,7 +407,20 @@ void draw_note(int n) {
if (!gfx_rows(40, 160)) return;
window(60, 40, 240, 160);
gfx_text_oc(FONT_HUD, 180, 48, note_title(n), C_GOLD);
- gfx_text_box(FONT_TEXT, 72, 72, 216, note_text(n), C_TEXT);
+ int h = gfx_text_box(FONT_TEXT, 72, 72, 216, note_text(n), C_TEXT);
+ /* its picture under the words: the enemy walking, the spell, the tower */
+ int arg = 0, kind = note_pic(n, &arg), y = 72 + h + (184 - 72 - h) * 3 / 4;
+ if (kind == 1) {
+ int an = enemy_anim[arg][0];
+ spr_anim(an, (int)(g.ticks % (uint32_t)anim_ticks(an)), false, 180, y, false);
+ } else if (kind == 2) {
+ spr_anim(arg == 1 ? AN_UI_PFIRE_IDLE : AN_UI_PREINF_IDLE, 0, false, 180, y - 4, false);
+ } else if (kind == 3) {
+ Spot t = {0};
+ t.kind = (uint8_t)arg, t.level = 4;
+ draw_base(&t, 180, y, 0);
+ draw_tower(&t, 180, y);
+ }
gfx_text_c(FONT_SMALL, 180, 184, "OK continue", C_DIM);
}
@@ -417,10 +433,10 @@ void draw_result(bool won, int stars, int mode, int sel, int t) {
for (int k = 0; k < 3; k++) {
int x = 150 + 30 * k, y = 100;
bool on = k < stars && t > 20 + 10 * k;
- spr_anim(AN_UI_FLAGSTAR, on ? 1 : 0, false, x - 7, y - 8, false);
+ if (on) spr_anim(AN_UI_STAR, 0, false, x - 7, y - 7, false);
+ else spr_frame_tint(anim_slot(AN_UI_STAR, 0, false), x - 7, y - 7, false, RGB(0x302820), 24);
if (on) gfx_ellipse(x, y, 9, 9, C_GOLD, 12);
}
- gfx_text_c(FONT_TEXT, 180, 120, stars == 3 ? "Flawless!" : stars == 2 ? "Well defended" : "The kingdom holds", C_TEXT);
} else
gfx_text_c(FONT_TEXT, 180, 100, mode == MODE_HEROIC ? "Heroic Challenge won: 1 star" : "Iron Challenge won: 1 star", C_TEXT);
} else
diff --git a/games/kingdomrush/tests/rules.c b/games/kingdomrush/tests/rules.c
index ceb484cc..3f1f2292 100644
--- a/games/kingdomrush/tests/rules.c
+++ b/games/kingdomrush/tests/rules.c
@@ -126,6 +126,11 @@ static void test_numbers(void) {
/* ------------------------------------------------------------------ a general */
static int bot_style;
+static int alive_enemies(void) {
+ int n = 0;
+ for (int i = 0; i < MAX_ENEMIES; i++) n += B.en[i].alive && !B.en[i].dead && i != B.veznan;
+ return n;
+}
static void general(void) {
/* spells: on the enemy furthest along */
int best = -1;
@@ -172,11 +177,11 @@ static int play_battle(int level, int mode, bool full_upgrades, int *lives) {
battle_start(level, mode);
for (int t = 0; t < 40; t++) battle_step();
battle_call_wave();
- for (int t = 0; t < 30 * 60 * 20 && B.state != LS_WIN && B.state != LS_OVER; t++) {
+ for (int t = 0; t < 30 * 60 * 60 && B.state != LS_WIN && B.state != LS_OVER; t++) {
battle_step();
if (t % 15 == 0) general();
if (B.pending_note) B.pending_note = 0;
- if (B.flags_up && mode == MODE_IRON) battle_call_wave();
+ if (B.flags_up && (mode == MODE_IRON || alive_enemies() < 4)) battle_call_wave(); /* (the general is in a hurry) */
}
*lives = B.lives;
return B.state;
@@ -300,6 +305,17 @@ int main(int argc, char **argv) {
int lvl = argc > 3 ? atoi(argv[3]) : 5;
play_start(lvl, MODE_CAMPAIGN);
for (int i = 0; i < 40; i++) step(0);
+ static const int notes[] = {1, 3, 17, 24}; /* a spell, an enemy, a tower, a flying enemy */
+ for (int k = 0; k < 4; k++) {
+ int n = notes[k];
+ g.p.seen_note[n >> 3] = (uint8_t)(g.p.seen_note[n >> 3] & ~(1 << (n & 7)));
+ B.pending_note = (uint8_t)n;
+ step(0);
+ game_draw();
+ snprintf(p, sizeof p, "%s/note%d.ppm", argv[2], n);
+ host_shot(p);
+ press(K_OK);
+ }
battle_call_wave();
bot_style = 1;
for (int t = 0; t < 30 * 150; t++) {
diff --git a/games/kingdomrush/tools/pack.py b/games/kingdomrush/tools/pack.py
index bf424562..0744173a 100644
--- a/games/kingdomrush/tools/pack.py
+++ b/games/kingdomrush/tools/pack.py
@@ -305,6 +305,12 @@ def ui_sprites():
anim("UI_FLAGSEL", ui_frames("flagdone", [3]), 1)
anim("UI_FLAGSTAR", ui_frames("flagstar", [1, 2]), 1)
anim("UI_FLAGHEROIC", ui_frames("flagheroic", [60]), 1)
+ # the map's road (its frames "1to2End" to "11to12End": the way so far), origin at the map's top left
+ anim("UI_ROAD", ui_frames("road", [18, 34, 53, 81, 109, 146, 159, 175, 200, 225, 250]), 1)
+ # MapStarProgress: its plank and star
+ sp = f"{KR}/render/u/starprog/1.png"
+ crop_icon("UI_STAR", sp, (101, 63, 115, 77))
+ crop_icon("UI_STARBOARD", sp, (52, 56, 120, 84))
# the upgrades' icons (in the game's order: barracks, archers, mages, artillery, rain, reinforcements) and their
# frames: available, locked, bought
anim("UI_UPICONS", ui_frames("upicons", range(1, 31)), 1)
@@ -663,7 +669,27 @@ def write_strings():
rows.append(("", ""))
out.append("static const char *const notes[][2] = {")
out += [f" {{{c_str(a)}, {c_str(b)}}}," for a, b in rows]
- out += ["};", "const char *note_title(int n) { return n > 0 && n < (int)(sizeof notes / sizeof notes[0]) ? notes[n][0] : 0; }",
+ out.append("};")
+ # the picture beside each: an enemy (1, its type), a spell (2, 1 fire 2 reinforcements), a tower (3, TW_*)
+ tw = {"RANGERS": "TW_RANGER", "ARCANE": "TW_ARCANE", "MUSKETEERS": "TW_MUSKETEER", "BARBARIANS": "TW_BARBARIAN",
+ "SORCERER": "TW_SORCERER", "TESLA": "TW_TESLA", "PALADINS": "TW_PALADIN", "BFG": "TW_BFG"}
+ pics = []
+ for n in NOTES:
+ if n.startswith("NotificationEnemy") and "Enemy" + n[len("NotificationEnemy"):] in ENEMY_IDS:
+ pics.append(f"{{1, {ENEMY_IDS['Enemy' + n[len('NotificationEnemy'):]]}}}")
+ elif n.startswith("NotificationPower"):
+ pics.append("{2, 1}" if "Fireball" in n else "{2, 2}")
+ elif isinstance(TOWER_OF.get(n), str):
+ pics.append(f"{{3, {tw[TOWER_OF[n]]}}}")
+ else:
+ pics.append("{0, 0}")
+ out.append("static const uint8_t note_pics[][2] = {" + ", ".join(pics) + "};")
+ out.append("int note_pic(int n, int *arg) {")
+ out.append(" if (n <= 0 || n >= (int)(sizeof note_pics / sizeof note_pics[0])) return 0;")
+ out.append(" *arg = note_pics[n][1];")
+ out.append(" return note_pics[n][0];")
+ out.append("}")
+ out += ["const char *note_title(int n) { return n > 0 && n < (int)(sizeof notes / sizeof notes[0]) ? notes[n][0] : 0; }",
"const char *note_text(int n) { return n > 0 && n < (int)(sizeof notes / sizeof notes[0]) && notes[n][1][0] ? notes[n][1] : 0; }", ""]
out.append("static const char *const enemy_desc_s[EN_COUNT] = {")
out += [f" {c_str(S.get('ENEMY_' + ENEMY_KEY[e] + '_DESCRIPTION', ''))}," for e in ENEMIES]
@@ -718,8 +744,6 @@ def main():
a[127:139, 282:320] = a[115:127, 282:320] # (the version number at the right edge)
pic("TITLE", Image.fromarray(a).convert("RGB"))
m = Image.open(f"{KR}/render/u/map/1.png").convert("RGBA")
- road = Image.open(f"{KR}/render/u/road/250.png").convert("RGBA")
- m.alpha_composite(road)
mp = m.crop((366, 366 + MAP_Y0, 686, 606 + MAP_Y0))
pic("MAP", mp.convert("RGB"))
define("MAP_Y0", MAP_Y0)