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
Celeste: exit blocks and fake walls are there when you come into a room
Mason36352659922f8f1
diff --git a/games/celeste/src/entities.c b/games/celeste/src/entities.cindex c56654c2..eb69a450 100644--- a/games/celeste/src/entities.c+++ b/games/celeste/src/entities.c@@ -1093,20 +1093,31 @@ static int dash_block_hit(Ent *e, Player *p, V2 dir) {}/* FakeWall, CoverupWall, ExitBlock: tiles that fade */+enum { BF_NO_LISTENER = 0x40 }; /* a FakeWall the player was in when it came: no TransitionListener */+static bool player_in(const Ent *e) {+ Ent *p = level_player_ent();+ return p && collide_ent_at(e, e->x, e->y, p);+}+static void fakewall_awake(Ent *e) {+ Block *b = ST(e, Block);+ if (!player_in(e)) return;+ b->alpha = 0, b->mode = 1, b->flags |= BF_NO_LISTENER;+ level_set_do_not_load(b->hash);+}static void fakewall_update(Ent *e) {Block *b = ST(e, Block);- Ent *p = level_player_ent();if (b->mode == 1) { /* fading */b->alpha = approach(b->alpha, 0, 2 * DT);if (b->alpha <= 0) ent_remove(e);return;}- if (p && collide_ent_at(e, e->x, e->y, p) && g_player.state != ST_DREAMDASH) {+ if (player_in(e) && g_player.state != ST_DREAMDASH) {level_set_do_not_load(b->hash);b->mode = 1;}}-static const EntClass FAKEWALL = {.size = sizeof(Block), .name = "fakeWall", .update = fakewall_update, .render = block_render};+static const EntClass FAKEWALL = {.size = sizeof(Block), .name = "fakeWall", .update = fakewall_update, .render = block_render,+ .awake = fakewall_awake};static void coverup_update(Ent *e) {Block *b = ST(e, Block);Ent *p = level_player_ent();@@ -1114,19 +1125,49 @@ static void coverup_update(Ent *e) {b->alpha = approach(b->alpha, in ? 0 : 1, 4 * DT);}static const EntClass COVERUP = {.size = sizeof(Block), .name = "coverupWall", .update = coverup_update, .render = block_render};+/* ExitBlock: there, unless the player is in it when it comes; then it closes once they are out */+static void exit_awake(Ent *e) {+ if (player_in(e)) ST(e, Block)->alpha = 0, e->collidable = 0;+}static void exit_update(Ent *e) {Block *b = ST(e, Block);- Ent *p = level_player_ent();- if (!e->collidable) {- e->collidable = 1;- bool in = p && collide_ent_at(e, e->x, e->y, p);- e->collidable = !in;- if (!in) b->mode = 1;- }- if (b->mode == 1) b->alpha = approach(b->alpha, 1, 2 * DT);plat_update(e);+ if (e->collidable) b->alpha = approach(b->alpha, 1, DT);+ else if (!player_in(e)) e->collidable = 1;+}+static const EntClass EXITBLOCK = {.size = sizeof(Block), .name = "exitBlock", .update = exit_update, .render = block_render,+ .awake = exit_awake, .kind = KIND_SOLID};++/* their TransitionListeners: those across the edge between the two rooms fade with the camera+ * (Block.step: TL_IN or TL_OUT; Block.timer: the alpha it fades out from) */+enum { TL_IN = 1, TL_OUT };+static bool on_room(const Ent *e, const Room *r) { /* Collide.CheckRect(e, bounds) */+ return e_right(e) > r->x && e_bottom(e) > r->y && e_left(e) < r->x + r->w && e_top(e) < r->y + r->h;+}+static bool listens(const Ent *e) {+ return e->dead != 1 && (e->cls == &EXITBLOCK || (e->cls == &FAKEWALL && !(ST(e, Block)->flags & BF_NO_LISTENER)));+}+void blocks_transition_begin(void) { /* OnOutBegin, OnInBegin: the next room is loaded (and awake) */+ const Room *prev = &g_level.rooms[g_level.room_slot ^ 1];+ for (Ent *e = g_ents; e < g_ents + g_nents; e++) {+ if (!e->cls || !listens(e)) continue;+ Block *b = ST(e, Block);+ b->step = 0;+ if (e->room != g_level.room_slot) {+ if (on_room(e, g_level.room)) b->step = TL_OUT, b->timer = b->alpha;+ } else if (on_room(e, prev) && (e->cls == &FAKEWALL || !player_in(e))) {+ b->step = TL_IN, b->alpha = 0;+ }+ }+}+void blocks_transition(void) { /* OnOut, OnIn */+ for (Ent *e = g_ents; e < g_ents + g_nents; e++) {+ if (!e->cls || !listens(e)) continue;+ Block *b = ST(e, Block);+ if (b->step == TL_IN) b->alpha = g_level.tr_at;+ else if (b->step == TL_OUT) b->alpha = b->timer * (1 - g_level.tr_at);+ }}-static const EntClass EXITBLOCK = {.size = sizeof(Block), .name = "exitBlock", .update = exit_update, .render = block_render, .kind = KIND_SOLID};/* Debris: bits of broken blocks */typedef struct { uint16_t tex; V2 speed; float life, rot, spin; } Debris;@@ -1478,10 +1519,7 @@ bool ent_create(const EData *d) {}case ET_exitBlock: {Ent *e = new_block(&EXITBLOCK, d, EA(d, exitBlock, width), EA(d, exitBlock, height), TILE_ATTR(d, exitBlock, tileType), true);- if (!e) return true;- e->depth = -13000;- e->collidable = 0;- ST(e, Block)->alpha = 0;+ if (e) e->depth = -13000;return true;}case ET_killbox: {diff --git a/games/celeste/src/level.c b/games/celeste/src/level.cindex 4a9a4e6d..cfd5eb3f 100644--- a/games/celeste/src/level.c+++ b/games/celeste/src/level.c@@ -596,6 +596,7 @@ static void transition_to(int index, V2 dir) {tiles_invalidate(); /* (the tiles at its edges with the other room) */ents_awake_new();cassette_level_start(true);+ blocks_transition_begin();Room *rm = g_level.room;g_level.transitioning = true;g_level.tr_dir = dir;@@ -627,6 +628,7 @@ static void transition_update(void) {g_level.tr_at = approach(g_level.tr_at, 1, DT / g_level.tr_duration);if (g_level.tr_at > 0.9f) g_level.cam = g_level.tr_cam_to;else g_level.cam = v2add(g_level.tr_cam_from, v2mul(v2sub(g_level.tr_cam_to, g_level.tr_cam_from), ease_cube_out(g_level.tr_at)));+ blocks_transition();if (arrived && g_level.tr_at >= 1) {int old = g_level.room_slot ^ 1;ents_remove_room(old);diff --git a/games/celeste/src/level.h b/games/celeste/src/level.hindex e79b4e06..fde799f7 100644--- a/games/celeste/src/level.h+++ b/games/celeste/src/level.h@@ -303,6 +303,8 @@ void tiles_overlay(char type, int x, int y, int w, int h, TileQ *out); /* blenvoid tiles_draw(const TileQ *q, char type, int w, int h, float x, float y, uint16_t tint, uint8_t alpha);TileQ *blocks_new_tiles(int n); /* n tiles for an entity of the room being made (NULL: none left), until it goes */void blocks_free_tiles(int slot); /* the room in that slot is gone: its blocks' tiles (entities.c) */+void blocks_transition_begin(void); /* FakeWall, ExitBlock: TransitionListener.OnOutBegin, OnInBegin */+void blocks_transition(void); /* and OnOut, OnIn *//* stylegrounds (style.c) */extern float g_snow_alpha; /* the Snow stylegrounds' Alpha */diff --git a/games/celeste/tests/check.py b/games/celeste/tests/check.pyindex 3d3b4ba5..a7cb7723 100644--- a/games/celeste/tests/check.py+++ b/games/celeste/tests/check.py@@ -133,6 +133,25 @@ for how, frames, keys in (("played", 2250, ",".join(f"{f}-{f + 2}:o" for f in rawhat=f"3A's lobby ({how})")check("room 00-a " in out, f"3A's lobby: Oshiro's door stayed shut, the cutscene {how}: {out[-160:]}")+# 3A's 11-b, come into from 12-b: the exit block over the way down from 11-c (top left) is there as the room comes in,+# not fading in after it (ExitBlock: hidden only from a player inside it)+def ppm(path):+ with open(path, "rb") as f:+ _, size, _, px = f.read().split(b"\n", 3)+ return int(size.split()[0]), px+++d = tempfile.mkdtemp(prefix="celeste_check_")+run(["--chapter", "7", "--room", "12-b", "--nowipe", "--shot", f"70:{d}/a.ppm", "--shot", f"150:{d}/b.ppm"], 151, "20-150:l",+ what="3A's 11-b exit block")+if os.path.exists(f"{d}/a.ppm") and os.path.exists(f"{d}/b.ppm"):+ (w, a), (_, b) = ppm(f"{d}/a.ppm"), ppm(f"{d}/b.ppm")+ changed = sum(1 for y in range(30, 60) for x in range(40) if max(abs(a[(y * w + x) * 3 + c] - b[(y * w + x) * 3 + c]) for c in range(3)) > 24)+ check(changed < 20, f"3A's 11-b: the way down from 11-c showed as the room came in ({changed} pixels)")+else:+ check(False, "3A's 11-b: no pictures")+shutil.rmtree(d, ignore_errors=True)+# 5A's c-10: its two touch switches (below the middle cracked block, on top of it) open the temple gate (TouchSwitches)# up on the right, the way to c-12out = run(["--chapter", "13", "--room", "c-10", "--nowipe"], 520,