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.

Celeste: climbing up to spikes on a ledge stops below them, as in the game (3A's key, Mason363/NumPlay#40)

Mason Chenb8911ebd6b54
diff --git a/games/celeste/src/berry.c b/games/celeste/src/berry.c
index f08625cf..3e201fd6 100644
--- a/games/celeste/src/berry.c
+++ b/games/celeste/src/berry.c
@@ -406,6 +406,11 @@ typedef struct {
} Seed;
static const EntClass SEED;
+bool leader_has_seed(void) {
+ for (int i = 0; i < nfol; i++)
+ if (fol[i].e->cls == &SEED) return true;
+ return false;
+}
static void seed_lose_leader(Ent *e) {
Seed *s = ST(e, Seed);
if (!s->finished) s->step = 1; /* the ReturnRoutine coroutine */
diff --git a/games/celeste/src/ch3.c b/games/celeste/src/ch3.c
index d1072ca5..3d2169af 100644
--- a/games/celeste/src/ch3.c
+++ b/games/celeste/src/ch3.c
@@ -1080,6 +1080,18 @@ static void ts_on_player(Ent *e, Player *p) {
}
}
}
+/* LedgeBlocker(UpSafeBlockCheck / SideSafeBlockCheck): a tendril out (Lerp 1) a hop ahead (up), or beside her (sides) */
+bool tspikes_ledge(const Ent *e, const Ent *pe, int facing) {
+ if (e->cls != &TSPIKES_CLASS) return false;
+ TSpikes *s = ST(e, TSpikes);
+ int mn, mx;
+ if (s->dir == TS_DOWN) return false;
+ if (s->dir == TS_UP) mn = (int)((e_left(pe) + 8 * facing - e_left(e)) / 4), mx = (int)((e_right(pe) + 8 * facing - e_left(e)) / 4);
+ else mn = (int)((e_top(pe) - e_top(e)) / 4), mx = (int)((e_bottom(pe) - e_top(e)) / 4);
+ for (int i = mn < 0 ? 0 : mn; i <= mx && i < s->n; i++)
+ if (ts_lerp[s->first + i] >= 255) return true;
+ return false;
+}
static bool ts_player_check(Ent *e, TSpikes *s, int i) {
Player *p = level_player();
if (!p || !collide_ent_at(e, e->x, e->y, p->ent)) return false;
diff --git a/games/celeste/src/dust.c b/games/celeste/src/dust.c
index 36139103..046d2411 100644
--- a/games/celeste/src/dust.c
+++ b/games/celeste/src/dust.c
@@ -478,6 +478,7 @@ static bool mover_new(const EData *d, bool rotate) {
}
/* DustStaticSpinner with attachToSolid (the static ones are the room's, spinner.c): rides the solid it overlaps */
+bool dust_ledge(const Ent *e) { return e->cls == &MOVER && ST(e, Mover)->attached; }
bool dust_spinner_new(const EData *d) {
if (!dust_room_of(d)) return false;
Ent *e = ent_new(&MOVER, d->x, d->y);
diff --git a/games/celeste/src/entities.c b/games/celeste/src/entities.c
index 03dc2599..57d09e30 100644
--- a/games/celeste/src/entities.c
+++ b/games/celeste/src/entities.c
@@ -259,6 +259,7 @@ static const EntClass SPIKES = {.size = sizeof(Spikes), .name = "spikes", .rende
.kind = KIND_PCOLLIDE | KIND_STATICMOVER | KIND_SPIKES,
.more = &(const EntMore){.sm_riding = spikes_riding,
.sm_shake = spikes_sm_shake, .sm_enable = spikes_sm_enable}};
+bool spikes_ledge(const Ent *e) { return e->cls == &SPIKES && ST(e, Spikes)->dir != DIR_DOWN; }
static void new_spikes(const EData *d, int dir) {
int size;
diff --git a/games/celeste/src/entities.h b/games/celeste/src/entities.h
index c4f6fdcc..ed8ab81c 100644
--- a/games/celeste/src/entities.h
+++ b/games/celeste/src/entities.h
@@ -92,6 +92,12 @@ void cassette_level_start(bool transition); /* the end of
bool cassette_block_scale(const Ent *block, V2 *origin, V2 *scale);
void cassette_blocks_finish(void);
void spikes_set_cassette(Ent *spikes, V2 origin);
+/* LedgeBlocker: whether e is one, for Madeline (pe, facing) (spikes but downward ones; dust tendrils, where they are out;
+ * attached dust bunnies; the other static spinners: spinners_hit_rect) */
+bool spikes_ledge(const Ent *e);
+bool tspikes_ledge(const Ent *e, const Ent *pe, int facing); /* (ch3.c) */
+bool dust_ledge(const Ent *e);
+bool leader_has_seed(void); /* a StrawberrySeed follows (berry.c) */
uint16_t cassette_tint(const Ent *blk, bool on); /* (cassette.c) its color for what it carries */
typedef struct { V2 a, b, c; float lerp; } CassetteFly; /* Player.cassetteFlyCurve, cassetteFlyLerp */
CassetteFly *cassette_fly(void);
diff --git a/games/celeste/src/player.c b/games/celeste/src/player.c
index 6d5821b2..8a8cdf47 100644
--- a/games/celeste/src/player.c
+++ b/games/celeste/src/player.c
@@ -1092,10 +1092,21 @@ static bool slip_check(float add_y) {
return !point_solid(ax, ay) && !point_solid(ax, ay + (-4 + add_y));
}
-static bool climb_hop_blocked_check(void) {
- if (solid_at(0, -6)) return true;
+/* a LedgeBlocker Madeline would collide with at (x, y) (Tracker.GetComponents<LedgeBlocker>) */
+static bool ledge_blocked(float x, float y) {
+ if (spinners_hit_rect(x + E->cx, y + E->cy, x + E->cx + E->cw, y + E->cy + E->ch)) return true;
+ for (int i = 0; i < g_nents; i++) {
+ Ent *o = &g_ents[i];
+ if (o->cls && o->collidable && o->dead != 1 && (spikes_ledge(o) || dust_ledge(o) || tspikes_ledge(o, E, P->facing)) &&
+ collide_ent_at(E, x, y, o))
+ return true;
+ }
return false;
}
+/* ClimbHopBlockedCheck: no hop onto spikes, spinners or tendrils (LedgeBlocker.HopBlockCheck), nor with seeds following */
+static bool climb_hop_blocked_check(void) {
+ return leader_has_seed() || ledge_blocked(E->x + P->facing * 8, E->y) || solid_at(0, -6);
+}
static void sweat_danger(int anim) {
if (P->stamina <= ClimbTiredThreshold) spr_play(&P->sweat, A_player_sweat_danger, false);
@@ -2537,7 +2548,8 @@ static void player_update(Ent *e) {
leader_update(v2(E->x, E->y - 8)); /* the Leader component, at (0, -8) */
actor_update_lift(E);
- if (!p->on_ground && p->speed.y <= 0 && (p->state != ST_CLIMB || p->last_climb_move == -1) && collide_jumpthru(E, E->x, E->y))
+ if (!p->on_ground && p->speed.y <= 0 && (p->state != ST_CLIMB || p->last_climb_move == -1) && collide_jumpthru(E, E->x, E->y) &&
+ !ledge_blocked(E->x, E->y - 2)) /* (JumpThruBoostBlockedCheck) */
actor_move_v(E, JumpThruAssistSpeed * DT, NULL, NULL);
if (!p->on_ground && player_dash_attacking(p) && p->dash_dir.y == 0)
if (solid_at(0, DashVFloorSnapDist) || jumpthru_outside_at(0, DashVFloorSnapDist)) actor_move_v_exact(E, DashVFloorSnapDist, NULL, NULL);
diff --git a/games/celeste/tests/check.py b/games/celeste/tests/check.py
index ae24f1a9..82b8fb77 100644
--- a/games/celeste/tests/check.py
+++ b/games/celeste/tests/check.py
@@ -105,6 +105,13 @@ out = run(["--chapter", "1", "--room", "1"], 300, "200-201:p,215-216:d,230-231:o
s = session(out)
check(s and s[3] == 1, f"Retry did not count a death: {s}")
+# 3A's start room (s3): onto the porch roof, up the posts with spikes on top (climbing on stops below them, as the
+# game's LedgeBlocker makes it), over them to the key, then through the locked door into the lobby
+out = run(["--chapter", "7", "--room", "s3", "--nowipe"], 780,
+ "10-90:r,58-70:j,100-110:j,108-112:u,108-109:x,116-133:r,150-160:j,150-182:l,150-345:g,184-249:u,250-262:j,"
+ "250-300:l,264-265:x,302-330:u,332-344:j,332-346:l,400-415:l,440-760:r,523-535:j", what="3A's key and locked door")
+check("room 0x-a " in out and " deaths 0 " in out, f"3A's start room was not crossed with its key: {out[-160:]}")
+
# a chapter's end: its screen, then the chapter select
out = run(["--chapter", "1", "--room", "1"], 500, "400-401:o", env={"COMPLETE_AT": "60"}, what="a chapter's end")