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.

Undertale: item texts readable, words wrapped by the font's widths, one pie slice

Mason3634cdfa734be73
diff --git a/games/undertale/src/menu.c b/games/undertale/src/menu.c
index d65379c7..f970c160 100644
--- a/games/undertale/src/menu.c
+++ b/games/undertale/src/menu.c
@@ -253,6 +253,7 @@ static void panel(int x, int y, int w, int h) {
}
static void draw_c_menu(void) {
+ if (msg_open) return; /* (an item's text: the menu closes for its box, as in the game) */
bool low = pl.y + 15 - cam_y < 130;
int oy = low ? 135 : 0;
char s[64];
diff --git a/games/undertale/src/ruins3.c b/games/undertale/src/ruins3.c
index 74a60e74..d909026e 100644
--- a/games/undertale/src/ruins3.c
+++ b/games/undertale/src/ruins3.c
@@ -58,7 +58,7 @@ void ruins3_setup(int room, int from) {
}
obj_sign(9260, 2498, 62, 34, "* (Toys you aren't interested\n in.)|* (An empty photo frame.)");
obj_sign(9335, 2498, 32, 48, "* (A box of shoes in many\n different sizes.)");
- if (flag(F_BED_SLEPT) == 1) {
+ if (flag(F_BED_SLEPT) == 1 && !flag(F_PIE)) { /* (once taken, gone) */
Obj *p = obj_deco(SPR_O_PIESLICE, 9322, 2572, false);
if (p) p->flags |= OF_TALK | OF_BACK, p->event = EV_ITEM, p->arg = flag(F_HARDMODE) ? ITEM_SNAIL_PIE : ITEM_BUTTERSCOTCH_PIE,
p->arg2 = F_PIE;
diff --git a/games/undertale/src/text.c b/games/undertale/src/text.c
index 227cbf65..65173cf4 100644
--- a/games/undertale/src/text.c
+++ b/games/undertale/src/text.c
@@ -86,14 +86,15 @@ static void layout(Writer *w) {
continue;
}
if (s[i] == ' ') last_space = i;
- int adv = s[i] == '$' ? 8 * (int)strlen(g_name) : 8;
+ /* (the font's own widths: its letters aren't all 8 pixels) */
+ int adv = s[i] == '$' ? gfx_text_width(w->font, g_name, (int)strlen(g_name)) : gfx_text_width(w->font, s + i, 1);
x += adv;
if (x > wrap_width && last_space > start && nbreaks < MAX_LINES) {
breaks[nbreaks++] = (uint16_t)(w->page + last_space);
/* the line after: indented under the first's words when the page starts with "* " */
- x = (s[0] == '*' ? 16 : 0);
+ x = (s[0] == '*' ? gfx_text_width(w->font, "* ", 2) : 0);
for (int k = last_space + 1; k <= i; k++)
- if (!code_len(s + k)) x += 8;
+ if (!code_len(s + k)) x += s[k] == '$' ? gfx_text_width(w->font, g_name, (int)strlen(g_name)) : gfx_text_width(w->font, s + k, 1);
start = last_space + 1;
last_space = -1;
}
diff --git a/games/undertale/tests/play.c b/games/undertale/tests/play.c
index 29e10ea2..4dca02f2 100644
--- a/games/undertale/tests/play.c
+++ b/games/undertale/tests/play.c
@@ -1,7 +1,7 @@
/* Plays Undertale on a computer, with scripted keys, and saves frames.
*
* play [--frames N] [--keys "10-40:right,50:z,..."] [--shots 30,60|all] [--out DIR] [--saves DIR]
- * [--room N --at X,Y] [--name NAME] [--flag F=V]... [--gold N] [--battle ID] [--trace]
+ * [--room N --at X,Y] [--name NAME] [--flag F=V]... [--gold N] [--item ID]... [--battle ID] [--trace]
*
* --path "x,y;x,y;z;w30;..." steers Frisk to each point in turn (holding arrows), presses Z ("z"), X ("x"),
* waits ("wN": N frames) or mashes Z through talks ("talk": until no text or event is left), when the scripted
@@ -361,7 +361,7 @@ int main(int argc, char **argv) {
const char *out = "build/play", *saves = NULL, *shots = "";
int frames = 120, room = -1, ax = 0, ay = 0, battle = -1;
const char *name = NULL;
- int nflags = 0, fl[64][2], gold = -1;
+ int nflags = 0, fl[64][2], gold = -1, nitems_ = 0, items_[8];
bool trace = false, coll = false, god = false;
for (int i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--frames") && i + 1 < argc) frames = atoi(argv[++i]);
@@ -399,6 +399,7 @@ int main(int argc, char **argv) {
else if (!strcmp(argv[i], "--noenc")) g_no_encounters = true;
else if (!strcmp(argv[i], "--god")) god = true;
else if (!strcmp(argv[i], "--gold") && i + 1 < argc) gold = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "--item") && i + 1 < argc && nitems_ < 8) items_[nitems_++] = atoi(argv[++i]);
else if (!strcmp(argv[i], "--coll")) coll = true;
else fprintf(stderr, "unknown option %s\n", argv[i]), exit(2);
}
@@ -425,6 +426,7 @@ int main(int argc, char **argv) {
}
for (int i = 0; i < nflags; i++) set_flag(fl[i][0], fl[i][1]);
if (gold >= 0) sv.gold = (uint16_t)gold;
+ for (int i = 0; i < nitems_; i++) item_add(items_[i]);
if (battle >= 0) battle_start(battle);
bool all = !strcmp(shots, "all");
for (int f = 0; f < frames && g_running; f++) {