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.
C calculatorcalculator-gamescasiochesscrossy-roaddrive-madfx-cg50gamesgeometry-dashgraphing-calculatorndlessnumworksnumworks-appsnumworks-calculatornumworks-gamenumworks-gamestetristi-84-plus-ceti-nspire
Undertale: Waterfall's walls and floors told apart by their waves
Mason363e3c2b5923f8b
diff --git a/games/undertale/src/data.bin b/games/undertale/src/data.binindex 4a64f0f6..c98b920f 100644Binary files a/games/undertale/src/data.bin and b/games/undertale/src/data.bin differdiff --git a/games/undertale/src/wf1.c b/games/undertale/src/wf1.cindex 1e7bda86..d83affbe 100644--- a/games/undertale/src/wf1.c+++ b/games/undertale/src/wf1.c@@ -428,8 +428,8 @@ void wf1_setup(int room, int from) {if (flag(F_MK_RAIN) == 1) {obj_mk(pl.x + 10, pl.y + 29, DIR_DOWN);mk_follows = true;- if (room == ROOM_WF_RAIN2) obj_trigger(12740, 1300, 60, 20, EV_MK_TALK, ACTOR_TRIGGER2);- else obj_trigger(13600, 1660, 20, 70, EV_MK_TALK, ACTOR_TRIGGER3);+ if (room == ROOM_WF_RAIN2) obj_trigger(12800, 1300, 60, 20, EV_MK_TALK, ACTOR_TRIGGER2);+ else obj_trigger(13600, 1700, 20, 80, EV_MK_TALK, ACTOR_TRIGGER3);}break;case ROOM_WF_AARON:diff --git a/games/undertale/src/world.c b/games/undertale/src/world.cindex bb9df1b1..3a3a519a 100644--- a/games/undertale/src/world.c+++ b/games/undertale/src/world.c@@ -382,9 +382,28 @@ static void front_box(int *x, int *y, int *w, int *h) {*x = fx, *y = fy, *w = fw, *h = fh;}+/* a 4-pixel row of floor across (x .. x + w) at y? */+static bool row_floor(int x, int y, int w) {+ for (int xx = x;; xx += 4) {+ if (xx > x + w - 1) xx = x + w - 1;+ if (cell_walkable(xx, y) || on_floor_obj(xx, y)) return true;+ if (xx == x + w - 1) return false;+ }+}++/* what Z reaches: the box in front, and facing a wall, up the wall to what's drawn on it (a sign, a glyph, a bell:+ * the game reads them from the wall's foot), never past it to the floor beyond */+void world_reach(int *x, int *y, int *w, int *h) {+ front_box(x, y, w, h);+ if (pl.dir != DIR_UP) return;+ int top = *y;+ for (int k = 0; k < 10 && !row_floor(*x, top - 4, *w); k++) top -= 4;+ *h += *y - top, *y = top;+}+static void interact(void) {int x, y, w, h;- front_box(&x, &y, &w, &h);+ world_reach(&x, &y, &w, &h);for (int i = 0; i < MAX_OBJS; i++) {Obj *o = &objs[i];if (o->kind == OBJ_NONE || !(o->flags & OF_TALK)) continue;diff --git a/games/undertale/src/world.h b/games/undertale/src/world.hindex e077a689..ebcb8019 100644--- a/games/undertale/src/world.h+++ b/games/undertale/src/world.h@@ -68,6 +68,7 @@ void world_update(uint32_t keys, uint32_t pressed);void world_draw(void);#define WALK_FLOOR_ONLY (-2) /* (world_walkable's ignore: the floor alone, nothing solid standing on it) */bool world_walkable(int x, int y, int w, int h, int ignore); /* a box on the map, objects too (not `ignore`) */+void world_reach(int *x, int *y, int *w, int *h); /* the box Z reaches, in front of Frisk */void world_camera(void); /* follows Frisk, inside the room */Obj *obj_new(int kind, int x, int y);Obj *obj_find(int name);diff --git a/games/undertale/tests/waterfall.path b/games/undertale/tests/waterfall.pathindex a601d5cf..8b47070f 100644--- a/games/undertale/tests/waterfall.path+++ b/games/undertale/tests/waterfall.path@@ -174,12 +174,15 @@ pick:1pick:1pick:3talk-go:10150,330+go:10150,362+10150,340go:10150,240go:10150,162uztalk+go:10150,264+10150,300go:10137,612dz@@ -205,14 +208,16 @@ go:11400,662go:11900,662talkgo:12500,662-go:12760,900+go:12815,900talk-go:12760,1500-go:12900,1700+go:12815,1500+go:12960,1670+13010,1670talk-go:13700,1700+go:13700,1722talk-go:14300,1700+go:14360,1722+14420,1722go:14720,1700talk# the last SAVE before the bridge, Undyne's spears from below, the bridge cutdiff --git a/games/undertale/tools/pack.py b/games/undertale/tools/pack.pyindex cfe9d681..489f06fd 100644--- a/games/undertale/tools/pack.py+++ b/games/undertale/tools/pack.py@@ -494,6 +494,55 @@ def floor_mask(area, r, x0, y0, x1, y1):return np.isin(area.idx[y0:y1, x0:x1], walk_idx)+def wave_walls(area, x0, y0, x1, y1):+ """the pixels of a rectangle of the map that are a wall drawn with waves (the area's "waves": line colour,+ background colours, reach, gap): Waterfall draws its walls and its darker floors in the same colours, the walls+ with waves across them, the floors dotted. A wave is a thin curve of the line colour, 12 pixels across or more;+ the wall is what's between two waves `gap` pixels apart or less, in each column, and `reach` pixels past the+ first and the last, up to the first pixel of another colour (the black line at the wall's foot)"""+ H, W = area.idx.shape+ pad = 24+ out = np.zeros((y1 - y0, x1 - x0), bool)+ xs0, ys0, xs1, ys1 = max(x0, 0), max(y0, 0), min(x1, W), min(y1, H)+ if xs1 <= xs0 or ys1 <= ys0:+ return out+ X0, Y0, X1, Y1 = max(0, xs0 - pad), max(0, ys0 - pad), min(W, xs1 + pad), min(H, ys1 + pad)+ win = area.idx[Y0:Y1, X0:X1]+ wall = np.zeros(win.shape, bool)+ for line, backs, reach, gap in area.spec.get("waves", []):+ is_line = np.isin(win, [i for i, k in enumerate(area.rgb) if k == tuple(line)])+ ok = is_line | np.isin(win, [i for i, k in enumerate(area.rgb) if k in [tuple(c) for c in backs]])+ lab, n = ndimage.label(is_line, structure=np.ones((3, 3), int))+ if not n:+ continue+ # thin (few of its pixels have the line colour all round) and long+ inner = is_line.copy()+ inner[1:] &= is_line[:-1]+ inner[:-1] &= is_line[1:]+ inner[:, 1:] &= is_line[:, :-1]+ inner[:, :-1] &= is_line[:, 1:]+ size = ndimage.sum(is_line, lab, range(n + 1))+ full = ndimage.sum(inner, lab, range(n + 1))+ good = np.zeros(n + 1, bool)+ for i, sl in enumerate(ndimage.find_objects(lab), 1):+ good[i] = sl[1].stop - sl[1].start >= 12 and full[i] <= 0.1 * size[i]+ wave = good[lab]+ # in each column, the last wave above and the last break (a pixel of another colour) above; the same below+ ys = np.arange(win.shape[0])[:, None]+ wa = np.maximum.accumulate(np.where(wave, ys, -1), axis=0)+ ba = np.maximum.accumulate(np.where(ok, -1, ys), axis=0)+ # (below: the same, rows counted from the bottom)+ wb = np.maximum.accumulate(np.where(wave[::-1], ys, -1), axis=0)[::-1]+ bb = np.maximum.accumulate(np.where(ok[::-1], -1, ys), axis=0)[::-1]+ above = wa > ba+ below = wb > bb+ top = win.shape[0] - 1+ da, db = ys - wa, (top - ys) - wb+ wall |= ok & ((above & below & (da + db <= gap)) | (above & (da <= reach)) | (below & (db <= reach)))+ out[ys0 - y0:ys1 - y0, xs0 - x0:xs1 - x0] = wall[ys0 - Y0:ys1 - Y0, xs0 - X0:xs1 - X0]+ return out++KEEP = -32768 # a door's landing: Frisk's own x or y, kept@@ -559,6 +608,8 @@ def collision(area, r):big = np.zeros((Y1 - Y0, X1 - X0), bool)xs0, ys0, xs1, ys1 = max(X0, 0), max(Y0, 0), min(X1, W), min(Y1, H)big[ys0 - Y0:ys1 - Y0, xs0 - X0:xs1 - X0] = np.isin(area.idx[ys0:ys1, xs0:xs1], list(walk_idx))+ if area.spec.get("waves"): # (walls in the floor's colours, told apart by their waves)+ big &= ~wave_walls(area, X0, Y0, X1, Y1)sub = big[margin:margin + ch * 4, margin:margin + cw * 4]if r.get("open"): # floors of many colours (a carpet, planks): its floor_rects alone saysub = np.ones_like(sub)diff --git a/games/undertale/tools/rooms.py b/games/undertale/tools/rooms.pyindex dd33449e..78978624 100644--- a/games/undertale/tools/rooms.py+++ b/games/undertale/tools/rooms.py@@ -118,7 +118,10 @@ WF_WATER = [(27, 33, 90), (27, 21, 72)]WF_CYAN = [(123, 251, 254), (47, 234, 255)]WF_DUMP = [(17, 11, 49), (18, 24, 71), (5, 6, 33), (15, 9, 47)] # (the dump's water, waded in)NAPSTA_FLOOR = [(198, 88, 41), (100, 50, 17), (133, 59, 41), (136, 68, 41)]-AREAS.append(dict(name="waterfall", map="Waterfall_map.png", floor=WF_FLOOR, margin=0, close=True, patches=[+AREAS.append(dict(name="waterfall", map="Waterfall_map.png", floor=WF_FLOOR, margin=0, close=True,+ waves=[((27, 21, 72), [(27, 33, 90)], 12, 26), ((27, 21, 72), [(0, 0, 0)], 2, 9),+ ((23, 13, 43), [(0, 0, 0)], 2, 9)],+ patches=[# the people the game moves about (they're the game's objects here): Monster Kid, the fish by the first# echo flower, Undyne (her black ledges kept black), Woshua, the Goner Kid, Onionsan, Shyren, the grey# figure by the piano, Aaron@@ -471,18 +474,18 @@ ROOMS = [dict(name="wf_hist", area="waterfall", rect=(2980, 400, 530, 380), title="Waterfall"),dict(name="wf_chase1", area="waterfall", rect=(4000, 300, 2520, 400), title="Waterfall"),dict(name="wf_grass1", area="waterfall", rect=(6520, 400, 1320, 300), title="Waterfall", floor_colors=WF_WATER,- floor_rects=[(6520, 540, 360, 72), (6880, 560, 960, 44)], fix=[("walk", 6520, 544, 360, 64)]),- dict(name="wf_sans2", area="waterfall", rect=(7840, 0, 360, 600), title="Waterfall", floor_colors=WF_WATER,- floor_rects=[(7860, 92, 300, 118), (7956, 206, 38, 360), (7840, 556, 360, 50)],+ floor_rects=[(6520, 540, 360, 72), (6880, 560, 960, 44), (7100, 520, 200, 40)], fix=[("walk", 6520, 544, 360, 64)]),+ dict(name="wf_sans2", area="waterfall", rect=(7840, 0, 360, 620), view=(7840, 0, 360, 660), title="Waterfall",+ floor_colors=WF_WATER, floor_rects=[(7860, 92, 300, 118), (7956, 206, 38, 360), (7840, 540, 360, 80)],fix=[("walk", 7956, 420, 38, 140)]),# the marsh, where the colours turn: its land is black, its water bright blue (the planks cross it), and around# it plain black is nothing (its rectangles); the boardwalk ends at a gap the bird carries Frisk over, a ladder# goes down into the marsh- dict(name="wf_marsh_top", area="waterfall", rect=(8200, 400, 450, 200), title="Waterfall",- floor_colors=WF_WATER + [(23, 13, 43), (0, 0, 0)], floor_rects=[(8200, 556, 284, 64), (8536, 556, 114, 64)]),- dict(name="wf_marsh_mid", area="waterfall", rect=(7400, 600, 1250, 200), title="Waterfall",- floor_colors=[(0, 0, 0)], floor_rects=[(8060, 600, 590, 100), (8060, 700, 110, 100), (7760, 780, 300, 20)],- fix=[("walk", 8140, 600, 20, 84)]),+ dict(name="wf_marsh_top", area="waterfall", rect=(8200, 400, 450, 220), view=(8200, 400, 450, 260), title="Waterfall",+ floor_colors=WF_WATER + [(23, 13, 43), (0, 0, 0)], floor_rects=[(8200, 560, 280, 60), (8540, 560, 110, 60)]),+ dict(name="wf_marsh_mid", area="waterfall", rect=(7400, 620, 1250, 180), title="Waterfall",+ floor_colors=[(0, 0, 0)], floor_rects=[(8060, 620, 590, 80), (8060, 700, 110, 100), (7760, 780, 300, 20)],+ fix=[("walk", 8140, 620, 20, 64)]),dict(name="wf_marsh", area="waterfall", rect=(7400, 800, 1650, 660), title="Waterfall",floor_colors=[(0, 0, 0)], floor_rects=[(7660, 800, 510, 660), (8170, 940, 190, 520), (8360, 1000, 380, 460),(8740, 800, 55, 660), (8795, 800, 85, 120), (8795, 1000, 265, 460),@@ -494,16 +497,24 @@ ROOMS = [floor_rects=[(8740, 656, 1160, 48), (8740, 656, 60, 144)], fix=[("walk", 9860, 660, 40, 40)]),dict(name="wf_piano", area="waterfall", rect=(9900, 20, 600, 780), title="Waterfall", floor_colors=WF_WATER,floor_rects=[(10060, 140, 200, 64), (10136, 200, 48, 104), (10118, 300, 64, 100), (10040, 398, 220, 64),- (10118, 460, 64, 140), (10040, 598, 220, 124), (9900, 638, 142, 46), (10258, 638, 242, 46)]),- dict(name="wf_statue", area="waterfall", rect=(10500, 520, 1000, 260), title="Waterfall", floor_colors=WF_WATER,- fix=[("walk", 10500, 640, 1000, 60)]),+ (10118, 460, 64, 140), (10040, 598, 220, 124), (9900, 660, 142, 40), (10258, 660, 242, 40)],+ # (the arch in the wall north of the piano: the way up to the artifact, once the piano has opened it)+ doors=[((10136, 376, 48, 8), "wf_piano", (10150, 258), "up"), ((10136, 294, 48, 6), "wf_piano", (10150, 384), "down")]),+ dict(name="wf_statue", area="waterfall", rect=(10500, 520, 1000, 260), title="Waterfall",+ floor_colors=WF_WATER + [(12, 9, 42), (10, 5, 23), (23, 13, 43), (12, 16, 53), (30, 25, 73), (73, 68, 128), (8, 12, 42)],+ floor_rects=[(10500, 640, 1000, 80)]), # (the rain, the statue's light)# (the rain's puddles are black)dict(name="wf_rain1", area="waterfall", rect=(11500, 520, 1360, 300), title="Waterfall",- floor_colors=WF_WATER + [(0, 0, 0)], floor_rects=[(11500, 636, 1360, 68), (12740, 700, 80, 120)]),- dict(name="wf_rain2", area="waterfall", rect=(12700, 820, 220, 980), title="Waterfall", floor_colors=WF_WATER),- dict(name="wf_castle", area="waterfall", rect=(12920, 1560, 1480, 260), title="Waterfall", floor_colors=WF_WATER,- fix=[("walk", 12920, 1676, 1480, 48)]),- dict(name="wf_aaron", area="waterfall", rect=(14400, 1560, 960, 260), title="Waterfall", floor_colors=WF_WATER),+ floor_colors=WF_WATER + [(0, 0, 0)], floor_rects=[(11500, 660, 1360, 60), (11880, 620, 60, 40), (12800, 720, 60, 100)]),+ dict(name="wf_rain2", area="waterfall", rect=(12700, 820, 300, 980), title="Waterfall", floor_colors=WF_WATER,+ floor_rects=[(12800, 820, 60, 900), (12800, 1660, 200, 60)],+ doors=[((12990, 1660, 10, 60), "wf_castle", (13004, 1726), "right")]),+ dict(name="wf_castle", area="waterfall", rect=(13000, 1560, 1400, 260), title="Waterfall", floor_colors=[],+ fix=[("walk", 13000, 1736, 1400, 40)],+ doors=[((13000, 1736, 6, 40), "wf_rain2", (12966, 1674), "left"),+ ((14394, 1736, 6, 40), "wf_aaron", (14406, 1680), "right")]),+ dict(name="wf_aaron", area="waterfall", rect=(14400, 1560, 960, 260), title="Waterfall", floor_colors=WF_WATER,+ doors=[((14400, 1680, 6, 60), "wf_castle", (14372, 1726), "left")]),dict(name="wf_bridge", area="waterfall", rect=(15360, 1540, 2300, 460), title="Waterfall"),# under the bridge: the garbage dump's landing (Frisk wades in its water), the Trash Zone, the walkway up to# Mad Dummy@@ -527,10 +538,10 @@ ROOMS = [# the twin waterfalls (waded through), the mushroom maze (its walls dotted lines of grass: kept clear of), Temmie# Village below itdict(name="wf_twin", area="waterfall", rect=(19850, 2200, 700, 220), title="Waterfall",- floor_colors=WF_WATER + WF_DUMP + [(0, 0, 0)], floor_rects=[(19850, 2286, 700, 48)]),+ floor_colors=WF_WATER + WF_DUMP + [(0, 0, 0)], floor_rects=[(19850, 2320, 700, 40)]),dict(name="wf_mushroom", area="waterfall", rect=(20550, 2280, 610, 600), title="Waterfall",- floor_colors=[(0, 0, 0)] + WF_WATER + WF_DUMP, margin=3, floor_rects=[(20550, 2306, 214, 48), (20555, 2350, 605, 530)],- fix=[("walk", 20550, 2310, 214, 40), ("walk", 20556, 2346, 212, 16), ("walk", 20764, 2320, 24, 40),+ floor_colors=[(0, 0, 0)] + WF_WATER + WF_DUMP, margin=3, floor_rects=[(20550, 2320, 214, 40), (20555, 2350, 605, 530)],+ fix=[("walk", 20550, 2320, 214, 40), ("walk", 20556, 2346, 212, 16), ("walk", 20764, 2320, 24, 40),("walk", 21020, 2372, 140, 26), ("walk", 21056, 2850, 44, 30)]),# (the way in, into the maze; out at its top right; the hidden way down to the village)dict(name="wf_temmie", area="waterfall", rect=(21020, 2880, 660, 320), title="Temmie Village", floor_colors=WF_WATER,