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: Oshiro's red trail is see-through as in the game

Mason Chen72db265c83c7
diff --git a/games/celeste/src/ch3.c b/games/celeste/src/ch3.c
index 9085273d..ba78c387 100644
--- a/games/celeste/src/ch3.c
+++ b/games/celeste/src/ch3.c
@@ -1901,7 +1901,7 @@ static void osh_update(Ent *e) {
break;
}
if (level_on_interval(0.05f)) {
- trail_add(e->x, e->y, ospr_tex(&o->spr), 48, 48, o->sx, o->sy, 0x990000, 0.5f, e->depth + 1);
+ trail_add(e->x, e->y, ospr_tex(&o->spr), 48, 48, o->sx, o->sy, 0x99990000 /* Color.Red * 0.6 */, 0.5f, e->depth + 1);
}
break;
case OS_WAITING:
diff --git a/games/celeste/src/fx.c b/games/celeste/src/fx.c
index a3f08121..06b4fb38 100644
--- a/games/celeste/src/fx.c
+++ b/games/celeste/src/fx.c
@@ -136,7 +136,8 @@ Trail *trail_add(float x, float y, uint16_t tex, float ox, float oy, float sx, f
memset(t, 0, sizeof *t);
t->x = (int16_t)floorf(x + 0.5f), t->y = (int16_t)floorf(y + 0.5f);
t->ox = ox, t->oy = oy, t->sx = sx, t->sy = sy, t->dur = dur;
- t->tex = tex, t->color = rgb(color), t->depth = (int16_t)depth;
+ t->tex = tex, t->color = rgb(color & 0xFFFFFF), t->depth = (int16_t)depth;
+ t->bangs = color >> 24 ? (uint8_t)(color >> 24) : 255; /* (no hair: the color's own alpha, premultiplied) */
t->born = (uint8_t)g_frame;
return t;
}
@@ -189,6 +190,8 @@ static void trail_strip(uint16_t *strip, int sy0, int sy1, void *ctx) {
int a8 = (int)(0.75f * e * e * e * 255), a = a8 + (a8 >> 7);
if (a <= 0) continue;
uint16_t pc = scale565(t->color, a);
+ int ca = t->nhair ? 256 : t->bangs + (t->bangs >> 7);
+ a = a * ca >> 8;
int cx = t->x - g_camx - 32, cy = t->y - g_camy - 32; /* the cell */
int y0 = cy > sy0 ? cy : sy0, y1 = cy + 64 < sy1 ? cy + 64 : sy1;
for (int Y = y0; Y < y1; Y++) {
diff --git a/games/celeste/src/fx.h b/games/celeste/src/fx.h
index eb409139..6839bb96 100644
--- a/games/celeste/src/fx.h
+++ b/games/celeste/src/fx.h
@@ -40,7 +40,7 @@ typedef struct {
int16_t x, y, depth; /* Position (rounded), Depth */
uint16_t tex, color; /* the frame; Color (RGB565) */
int8_t sdy; /* the sprite's offset */
- uint8_t born, nhair, bangs; /* the frame added; PlayerHair's nodes, its bangs frame */
+ uint8_t born, nhair, bangs; /* the frame added; PlayerHair's nodes, its bangs frame (no hair: the color's alpha) */
int8_t hair[TRAIL_HAIR][2]; /* the nodes (as drawn: rounded) from Position */
} Trail;
Trail *trail_add(float x, float y, uint16_t tex, float ox, float oy, float sx, float sy, uint32_t color, float duration, int depth);