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.

Champion Island: the doodle's banner and text sizes, rules panel OK button

Mason Chen8e9c97db0e05
diff --git a/games/championisland/src/data.bin b/games/championisland/src/data.bin
index 327fa796..5cba9328 100644
Binary files a/games/championisland/src/data.bin and b/games/championisland/src/data.bin differ
diff --git a/games/championisland/src/font.c b/games/championisland/src/font.c
index e3379c9d..7b178d50 100644
--- a/games/championisland/src/font.c
+++ b/games/championisland/src/font.c
@@ -25,16 +25,19 @@ static int glyph(uint32_t c) {
return c == 0x2014 ? 104 : -1; /* em dash as en dash */
}
-static int K = 1;
-void font_scale(int k) { K = k < 1 ? 1 : k; }
+/* the scale in thirds: 3 is the font's 10 px, 8 is 26.7 px (a doodle text of
+ * 80 px on the 960 x 540 stage); a font pixel covers 1 to K3 / 3 + 1 pixels */
+static int K3 = 3;
+void font_scale(int k) { K3 = k < 1 ? 3 : 3 * k; }
+void font_scale3(int k3) { K3 = k3 < 1 ? 1 : k3; }
int font_width(const char *s, const char *end) {
int w = 0;
while (s < end && *s) {
int g = glyph(utf8(&s));
- w += (g < 0 ? 5 : font_adv[g]) * K;
+ w += g < 0 ? 5 : font_adv[g];
}
- return w;
+ return (w * K3 + 2) / 3;
}
/* Calls fn for each line of s wrapped at lw pixels (lw <= 0: no wrapping). */
@@ -83,8 +86,8 @@ static void measure_line(const char *a, const char *b, int w, int index, void *c
void font_measure(const char *s, int lw, int lh, int *w, int *h) {
*w = 0;
int n = lines(s, lw, measure_line, w);
- int l = lh > 0 ? lh : FONT_LINE * K;
- *h = n * l - l + FONT_HEIGHT * K;
+ int l = lh > 0 ? lh : FONT_LINE * K3 / 3;
+ *h = n * l - l + FONT_HEIGHT * K3 / 3;
}
typedef struct {
@@ -103,30 +106,28 @@ static inline uint16_t blend(uint16_t fg, uint16_t bg, unsigned a) {
static void draw_line(const char *a, const char *b, int w, int index, void *vctx) {
DrawCtx *c = vctx;
int y = c->oy + index * c->lh;
- if (y + FONT_HEIGHT * K <= c->by || y >= c->by + c->rows) return;
- int x = c->ox - (c->align == 1 ? w / 2 : c->align == 2 ? w : 0);
+ if (y + FONT_HEIGHT * K3 / 3 <= c->by || y >= c->by + c->rows) return;
+ int x3 = 3 * (c->ox - (c->align == 1 ? w / 2 : c->align == 2 ? w : 0)); /* in thirds of a pixel */
while (a < b) {
int g = glyph(utf8(&a));
- if (g < 0) { x += 5 * K; continue; }
- for (int r = 0; r < FONT_HEIGHT * K; r++) {
+ if (g < 0) { x3 += 5 * K3; continue; }
+ for (int r = 0; r < FONT_HEIGHT * K3 / 3; r++) {
int sy = y + r - c->by;
if (sy < 0 || sy >= c->rows) continue;
- uint16_t bits = font_bits[g][r / K];
+ uint16_t bits = font_bits[g][r * 3 / K3];
uint16_t *d = c->band + sy * c->stride;
for (int i = 0; bits; i++, bits >>= 1)
if (bits & 1)
- for (int q = 0; q < K; q++) {
- int sx = x + i * K + q;
+ for (int sx = (x3 + i * K3) / 3; sx < (x3 + (i + 1) * K3) / 3; sx++)
if ((unsigned)sx < (unsigned)c->stride) d[sx] = c->ga >= 32 ? c->color : blend(c->color, d[sx], c->ga);
- }
}
- x += font_adv[g] * K;
+ x3 += font_adv[g] * K3;
}
}
void font_draw(const char *s, uint8_t align, int lw, int lh, int ox, int oy, uint16_t *band, int by, int rows, int stride,
uint16_t color, unsigned ga) {
- DrawCtx c = {ox, oy, lh > 0 ? lh : FONT_LINE * K, by, rows, stride, align, band, color, ga};
+ DrawCtx c = {ox, oy, lh > 0 ? lh : FONT_LINE * K3 / 3, by, rows, stride, align, band, color, ga};
lines(s, lw, draw_line, &c);
}
diff --git a/games/championisland/src/font.h b/games/championisland/src/font.h
index 89ee5c35..24e51096 100644
--- a/games/championisland/src/font.h
+++ b/games/championisland/src/font.h
@@ -6,6 +6,7 @@
#define FONT_LINE 12
void font_scale(int k); /* 1: the font's 10 px, 2 and 3 for big texts */
+void font_scale3(int k3); /* in thirds: 3 is 10 px, 8 is 26.7 px, 10 is 33.3 px */
int font_width(const char *s, const char *end);
void font_measure(const char *s, int lw, int lh, int *w, int *h);
int font_lines(const char *s, int lw);
diff --git a/games/championisland/src/game.c b/games/championisland/src/game.c
index e6db73ff..07592c08 100644
--- a/games/championisland/src/game.c
+++ b/games/championisland/src/game.c
@@ -160,6 +160,7 @@ static void switch_scene(void) {
if (!def) return;
if (game.def && game.def->end) game.def->end();
if (game.root) node_free(game.root);
+ toast_style("", 0, -1, -1); /* Hq: a new scene takes the banner away */
state_bytes = 0;
mem_layout(0, 0, 0, NULL);
memset(&in.pressed, 0, sizeof in.pressed);
@@ -199,19 +200,53 @@ void game_tick(void) {
}
}
-/* ---------------------------------------------------------------- toast */
-static char toast_text[64];
-static int toast_t;
-static bool toast_big;
-void toast(const char *t) {
- snprintf(toast_text, sizeof toast_text, "%s", t);
- toast_t = 75;
- toast_big = false;
+/* ---------------------------------------------------------------- the banner */
+/* To(): one message at a time at (480, 151) on the stage, in PixelMplus at
+ * `size` px over a shadow (alpha .8, size / 12 lower) and an outline, in from
+ * the right in 400 ms (cubicOut), still for 2 s, out to the left in 300 ms
+ * (cubicIn); a new one takes the place of the last */
+static struct { char text[64]; int t, size; int32_t shadow, outline, color; } ban = {"", -1, 0, -1, -1, 0xffffff};
+void toast_full(const char *t, int size, int32_t shadow, int32_t outline, int32_t color) {
+ snprintf(ban.text, sizeof ban.text, "%s", t ? t : "");
+ ban.t = ban.text[0] ? 0 : -1;
+ ban.size = size;
+ ban.shadow = shadow;
+ ban.outline = outline;
+ ban.color = color;
}
-void toast_countdown(const char *t) {
- toast(t);
- toast_big = true;
- toast_t = 45;
+void toast_style(const char *t, int size, int32_t shadow, int32_t outline) { toast_full(t, size, shadow, outline, 0xffffff); }
+void toast(const char *t) { toast_style(t, 80, 0x111111, 0x555555); }
+void toast_countdown(const char *t) { toast_style(t, 100, 0x222222, 0xaaaaaa); }
+
+static uint16_t hex565(int32_t c) { return rgb565((uint8_t)(c >> 16), (uint8_t)(c >> 8), (uint8_t)c); }
+
+static void banner_draw(void) {
+ if (ban.t < 0) return;
+ enum { IN = 12, HOLD = 60, OUT = 9 };
+ int t = ban.t++;
+ float off = 0;
+ if (t < IN) { float u = 1 - t / (float)IN; off = 1000 * u * u * u; }
+ else if (t >= IN + HOLD) { float u = (t - IN - HOLD) / (float)OUT; off = -1000 * u * u * u; }
+ if (t >= IN + HOLD + OUT) { ban.t = -1; return; }
+ int k3 = (ban.size + 5) / 10;
+ Mat m = MAT_ID;
+ m.tx = floorf((480 + off) / 3 + .5f);
+ m.ty = floorf((540 * .28f - ban.size / 2.0f) / 3 + .5f) - k3 / 3; /* the canvas sets the font a pixel higher */
+ if (ban.shadow >= 0) {
+ Mat s = m;
+ s.ty += floorf(ban.size / 12.0f / 3 + .5f);
+ gfx_text_k3(ban.text, s, hex565(ban.shadow), 1, 0, 0, 204, k3);
+ }
+ if (ban.outline >= 0) {
+ static const int8_t o[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
+ for (int i = 0; i < 4; i++) {
+ Mat q = m;
+ q.tx += o[i][0];
+ q.ty += o[i][1];
+ gfx_text_k3(ban.text, q, hex565(ban.outline), 1, 0, 0, 255, k3);
+ }
+ }
+ gfx_text_k3(ban.text, m, hex565(ban.color), 1, 0, 0, 255, k3);
}
void game_draw(void) {
@@ -222,18 +257,7 @@ void game_draw(void) {
hud_draw();
dialog_draw();
menus_draw();
- if (toast_t > 0) {
- toast_t--;
- Mat m = MAT_ID;
- m.tx = VIEW_W / 2;
- m.ty = 50;
- uint8_t a = toast_t < 10 ? (uint8_t)(toast_t * 25) : 255;
- Mat s = m;
- s.tx += 1; s.ty += 1;
- int k = toast_big ? 3 : 2;
- gfx_text_k(toast_text, s, rgb565(0x22, 0x22, 0x22), 1, 0, 0, a, k);
- gfx_text_k(toast_text, m, rgb565(0xff, 0xff, 0xff), 1, 0, 0, a, k);
- }
+ banner_draw();
if (game.fade > 0 && game.fade <= 8) gfx_rect(0, 0, VIEW_W, VIEW_H, 0, (uint8_t)(game.fade * 255 / 8));
else if (game.fade > 8) gfx_rect(0, 0, VIEW_W, VIEW_H, 0, 255);
gfx_end();
diff --git a/games/championisland/src/game.h b/games/championisland/src/game.h
index 2a257315..92c78ff0 100644
--- a/games/championisland/src/game.h
+++ b/games/championisland/src/game.h
@@ -85,8 +85,10 @@ void hud_init(void);
void hud_tick(void);
void hud_draw(void);
-void toast(const char *text); /* the doodle's centred message */
-void toast_countdown(const char *text); /* 3, 2, 1, GO */
+void toast(const char *text); /* the doodle's banner (To): 80 px, dark shadow and outline */
+void toast_countdown(const char *text); /* 3, 2, 1, GO: 100 px */
+void toast_style(const char *text, int size, int32_t shadow, int32_t outline); /* colours 0xRRGGBB, -1: none */
+void toast_full(const char *text, int size, int32_t shadow, int32_t outline, int32_t color);
/* sounds are not played (the calculator has no speaker) */
#define SOUND(x) ((void)0)
diff --git a/games/championisland/src/gfx.c b/games/championisland/src/gfx.c
index b7da9eb1..dff8b7a0 100644
--- a/games/championisland/src/gfx.c
+++ b/games/championisland/src/gfx.c
@@ -155,9 +155,13 @@ void gfx_shape(const uint8_t *shape, Mat m, uint8_t alpha) {
void gfx_text(const char *s, Mat m, uint16_t color, uint8_t align, int16_t lw, int16_t lh, uint8_t alpha) { gfx_text_k(s, m, color, align, lw, lh, alpha, 1); }
void gfx_text_k(const char *s, Mat m, uint16_t color, uint8_t align, int16_t lw, int16_t lh, uint8_t alpha, int k) {
+ gfx_text_k3(s, m, color, align, lw, lh, alpha, 3 * k);
+}
+
+void gfx_text_k3(const char *s, Mat m, uint16_t color, uint8_t align, int16_t lw, int16_t lh, uint8_t alpha, int k3) {
if (!s || !*s || !alpha) return;
int w, h;
- font_scale(k);
+ font_scale3(k3);
font_measure(s, lw, lh, &w, &h);
font_scale(1);
int ox = align == 1 ? -w / 2 : align == 2 ? -w : 0;
@@ -172,7 +176,7 @@ void gfx_text_k(const char *s, Mat m, uint16_t color, uint8_t align, int16_t lw,
affs[naffs].lw = lw;
affs[naffs].lh = lh;
affs[naffs].m = m;
- affs[naffs].scale = (uint8_t)k;
+ affs[naffs].scale = (uint8_t)k3;
it->ref = (uint16_t)naffs++;
} else nitems--;
}
@@ -792,7 +796,7 @@ static __attribute__((noinline)) void draw_tiles_item(int y0, int y1, int by, un
static __attribute__((noinline)) void draw_text_item(const Item *it, int y0, int y1, int by, int rows, unsigned ga) {
const Aff *f = &affs[it->ref];
- font_scale(f->scale);
+ font_scale3(f->scale);
font_draw(item_ptr[it->ref], f->align, f->lw, f->lh, (int)floorf(f->m.tx), (int)floorf(f->m.ty), band, by, rows, VIEW_W, it->color, ga);
font_scale(1);
}
@@ -882,6 +886,12 @@ void gfx_end(void) {
fprintf(stderr, "items %d: sprite %d/%ld affine %d/%ld rect %d/%ld shape %d/%ld text %d/%ld stream %d/%ld\n", nitems,
cnt[0], area[0], cnt[1], area[1], cnt[2], area[2], cnt[3], area[3], cnt[4], area[4], cnt[5], area[5]);
}
+#endif
+#ifdef HOST
+ if (getenv("CI_ITEMS"))
+ for (int i = 0; i < nitems; i++)
+ fprintf(stderr, "item %d kind %d a %d f %d box %d %d %d %d ref %u col %u\n", i, items[i].kind, items[i].alpha, items[i].flags,
+ items[i].x0, items[i].y0, items[i].x1, items[i].y1, items[i].ref, items[i].color);
#endif
/* decode what the frame needs before drawing, so bands only read the cache */
streaming = NULL;
diff --git a/games/championisland/src/gfx.h b/games/championisland/src/gfx.h
index cb15c46c..8adec55a 100644
--- a/games/championisland/src/gfx.h
+++ b/games/championisland/src/gfx.h
@@ -22,6 +22,7 @@ void gfx_tiles(const uint8_t *px, int w, int h, const uint16_t *pal, const uint8
/* text: font size in px of the doodle's layout, colour RGB565 */
void gfx_text(const char *s, Mat m, uint16_t color, uint8_t align, int16_t line_w, int16_t line_h, uint8_t alpha);
void gfx_text_k(const char *s, Mat m, uint16_t color, uint8_t align, int16_t line_w, int16_t line_h, uint8_t alpha, int scale);
+void gfx_text_k3(const char *s, Mat m, uint16_t color, uint8_t align, int16_t line_w, int16_t line_h, uint8_t alpha, int k3); /* scale in thirds */
void gfx_end(void); /* rasterise and push the bands that changed */
void gfx_redraw_all(void); /* next frame: every band */
void gfx_clear_color(uint16_t c); /* what shows where nothing is drawn */
diff --git a/games/championisland/src/node.c b/games/championisland/src/node.c
index 60af4008..2600af64 100644
--- a/games/championisland/src/node.c
+++ b/games/championisland/src/node.c
@@ -146,6 +146,8 @@ static void apply_key(NodeId c, const Key *k, uint16_t idx) {
n->ry4 = k->ry4;
n->mat = k->mat;
n->alpha = k->alpha;
+ /* a text or shape keyframe can change its look (a button's label turns white on focus) */
+ if ((n->kind == NK_TEXT && k->kind == CK_TEXT) || (n->kind == NK_SHAPE && k->kind == CK_SHAPE)) n->ref = k->ref;
if (k->flags & K_HIDDEN) n->flags &= (uint8_t)~NF_VISIBLE;
else n->flags |= NF_VISIBLE;
/* setting a transform from the timeline drops the code's */
@@ -1010,6 +1012,24 @@ static void draw_virtual(uint16_t sym, unsigned frame, Mat m, uint8_t alpha, int
static const char *text_of(NodeId n);
static int32_t text_color(NodeId n);
+/* a text node's text s (NULL: its own), placed by m (the view's), as the
+ * doodle's canvas sets it: the size on screen picks the font's scale (in
+ * thirds; small texts keep the crisp 10 px), the baseline its offset (the
+ * canvas puts PixelMplus a font pixel higher than its rows), colour -1: the
+ * node's own */
+void node_text_draw(NodeId id, Mat m, const char *s, int32_t color, uint8_t alpha) {
+ const Node *n = &nodes[id];
+ if (n->kind != NK_TEXT || n->ref == NONE16 || !alpha) return;
+ const uint8_t *t = payload(n->ref);
+ if (!s) s = text_of(id);
+ float scale = sqrtf(m.a * m.a + m.b * m.b), px = t[2] * scale;
+ int k3 = px >= 11.5f ? (int)(px * 0.3f + .5f) : 3;
+ int lw = (int)(rds16(t + 8) * 0.25f * scale), lh = (int)(rds16(t + 10) * 0.25f * scale);
+ if (lh > 0 && lh < FONT_LINE * k3 / 3) lh = FONT_LINE * k3 / 3;
+ m.ty += (t[7] == 1 ? -6 : t[7] >= 2 ? -10 : -1) * k3 / 3; /* top, middle, alphabetic */
+ gfx_text_k3(s, m, color >= 0 ? (uint16_t)color : rgb565(t[3], t[4], t[5]), t[6], (int16_t)lw, (int16_t)lh, alpha, k3);
+}
+
static void draw_rec(NodeId id, Mat parent, uint8_t alpha) {
const Node *n = &nodes[id];
if ((n->flags & (NF_VISIBLE | NF_ONSTAGE)) != (NF_VISIBLE | NF_ONSTAGE) || !n->alpha) return;
@@ -1021,20 +1041,8 @@ static void draw_rec(NodeId id, Mat parent, uint8_t alpha) {
case NK_SHAPE: if (n->ref != NONE16) gfx_shape(payload(n->ref), m, al); return;
case NK_TEXT: {
if (n->ref == NONE16) return;
- const uint8_t *t = payload(n->ref);
- /* sid, size, r, g, b, align, baseline, lineWidth*4, lineHeight*4 */
- const char *s = text_of(id);
- float scale = sqrtf(m.a * m.a + m.b * m.b);
- /* the text's size on screen picks the font's scale: 10 px, 20 or 30 */
- float px = t[2] * scale;
- int k = px >= 26 ? 3 : px >= 16 ? 2 : 1;
- int lw = (int)(rds16(t + 8) * 0.25f * scale), lh = (int)(rds16(t + 10) * 0.25f * scale);
- if (lh > 0 && lh < FONT_LINE * k) lh = FONT_LINE * k;
- int yoff = t[7] == 1 ? -5 * k : t[7] >= 2 ? -9 * k : 0; /* middle / alphabetic baselines */
- Mat tm = m;
- tm.ty += yoff;
int32_t tc = text_color(id);
- gfx_text_k(s, tm, tc >= 0 ? (uint16_t)tc : rgb565(t[3], t[4], t[5]), t[6], (int16_t)lw, (int16_t)lh, al, k);
+ node_text_draw(id, m, text_of(id), tc, al);
return;
}
default: break;
diff --git a/games/championisland/src/node.h b/games/championisland/src/node.h
index 5308c1af..5ef6e5e5 100644
--- a/games/championisland/src/node.h
+++ b/games/championisland/src/node.h
@@ -111,6 +111,7 @@ bool node_slot_bounds(NodeId n, unsigned slot, float *x, float *y, float *w, flo
/* drawing */
void node_draw(NodeId root, Mat m);
+void node_text_draw(NodeId text, Mat m, const char *s, int32_t color, uint8_t alpha); /* s NULL: its own, colour -1: its own */
void node_draw_in(NodeId n, Mat parent, uint8_t alpha); /* n in a parent drawn with `parent` */
void node_draw_sym(uint16_t sym, unsigned frame, Mat m, uint8_t alpha); /* a symbol's frame, without nodes */
/* one node drawn by code instead (its matrix and alpha computed): the island's map */
diff --git a/games/championisland/src/sport_archery.c b/games/championisland/src/sport_archery.c
index 4946bdd9..e715636f 100644
--- a/games/championisland/src/sport_archery.c
+++ b/games/championisland/src/sport_archery.c
@@ -41,15 +41,6 @@ typedef struct {
typedef struct { uint8_t side; uint8_t type; int16_t ymin, ymax; int wait, every; bool on; } Spawner; /* bp */
-typedef struct {
- const char *text;
- int t, hold;
- uint8_t k;
- float dy;
- uint16_t shadow, outline;
- bool on;
-} Banner;
-
typedef struct {
NodeId root, map, hud, player, champ, overlay;
NodeId back, sky; /* the background clip, its gradient (drawn as bands) */
@@ -79,7 +70,6 @@ typedef struct {
bool counting, uo;
bool over, reported;
int end_t, rating;
- Banner banner;
int last[6];
int arrow_f, carrow_f; /* the arrow meters' frames */
char s_score[12], s_cscore[12], s_time[12];
@@ -294,46 +284,6 @@ static void goto_frame(NodeId n, int f, int *last) { /* gotoAndStop(frame), on
*last = f;
}
-/* ---------------------------------------------------------------- the banner (To) */
-static void banner(const char *text, int size, uint16_t shadow, uint16_t outline) {
- Banner *b = &S->banner;
- b->text = text;
- b->t = 0;
- b->hold = 60;
- b->k = size >= 26 * 3 ? 3 : 2;
- b->dy = size / 3.0f / 12;
- b->shadow = shadow;
- b->outline = outline;
- b->on = true;
-}
-
-static void banner_draw(void) {
- Banner *b = &S->banner;
- if (!b->on || !b->text) return;
- float off;
- int t = b->t;
- if (t < 12) { float u = 1 - t / 12.0f; off = 1000 / 3.0f * u * u * u; }
- else if (t < 12 + b->hold) off = 0;
- else { float u = (t - 12 - b->hold) / 9.0f; off = -1000 / 3.0f * u * u * u; }
- if (t >= 12 + b->hold + 9) { b->on = false; return; }
- int h = FONT_HEIGHT * b->k;
- Mat m = MAT_ID;
- m.tx = floorf(160 + off);
- m.ty = floorf(540 * .28f / 3 - h / 2.0f + .5f) - 1;
- Mat s = m;
- s.ty += floorf(b->dy + .5f);
- gfx_text_k(b->text, s, b->shadow, 1, 0, 0, 204, b->k);
- static const int8_t o[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
- for (int i = 0; i < 4; i++) {
- Mat q = m;
- q.tx += o[i][0];
- q.ty += o[i][1];
- gfx_text_k(b->text, q, b->outline, 1, 0, 0, 255, b->k);
- }
- gfx_text_k(b->text, m, rgb565(255, 255, 255), 1, 0, 0, 255, b->k);
- b->t++;
-}
-
/* ---------------------------------------------------------------- records */
static void kill_target(Target *t) { /* co(): removeFx shows the broken target */
if (t->dead) return;
@@ -706,7 +656,7 @@ static void clock_end(void) {
S->over = true;
S->end_t = 80;
SOUND(end);
- banner(msg(0 < g ? "YOU_WIN" : "YOICHI_WINS"), 80, rgb565(0x11, 0x11, 0x11), rgb565(0x55, 0x55, 0x55));
+ toast_style(msg(0 < g ? "YOU_WIN" : "YOICHI_WINS"), 80, 0x111111, 0x555555);
}
/* ---------------------------------------------------------------- Pp: draw order */
@@ -799,11 +749,11 @@ static void start(void) {
/* ---------------------------------------------------------------- the systems */
static void countdown(void) { /* Wo */
if (!S->counting) return;
- uint16_t sh = rgb565(0x22, 0x22, 0x22), ol = rgb565(0xaa, 0xaa, 0xaa);
- if (S->cd == 90) { banner("3", 100, sh, ol); SOUND(beep); }
- else if (S->cd == 60) { banner("2", 100, sh, ol); SOUND(beep); }
- else if (S->cd == 30) { banner("1", 100, sh, ol); SOUND(beep); }
- else if (S->cd == 0) { banner(msg("GO"), 100, sh, ol); SOUND(go); S->counting = false; }
+ int32_t sh = 0x222222, ol = 0xaaaaaa;
+ if (S->cd == 90) { toast_style("3", 100, sh, ol); SOUND(beep); }
+ else if (S->cd == 60) { toast_style("2", 100, sh, ol); SOUND(beep); }
+ else if (S->cd == 30) { toast_style("1", 100, sh, ol); SOUND(beep); }
+ else if (S->cd == 0) { toast_style(msg("GO"), 100, sh, ol); SOUND(go); S->counting = false; }
if (S->cd > 0) S->cd--;
}
@@ -914,12 +864,8 @@ static void draw_popup(NodeId f, Mat parent) {
for (NodeId t = nodes[a].first; t; t = nodes[t].next) {
if (nodes[t].kind != NK_TEXT || !node_visible(t) || nodes[t].ref == NONE16) continue;
Mat mt = mat_mul(ma, node_local(t));
- const uint8_t *pl = payload(nodes[t].ref);
const char *s = node_text(t);
- float scale = sqrtf(mt.a * mt.a + mt.b * mt.b), px = pl[2] * scale;
- int k = px >= 26 ? 3 : px >= 16 ? 2 : 1;
- int lw = (int)(rds16(pl + 8) * .25f * scale);
- gfx_text_k(s, mt, popup_color(s), pl[6], (int16_t)lw, 0, (uint8_t)(al * nodes[t].alpha / 255), k);
+ node_text_draw(t, mt, s, popup_color(s), (uint8_t)(al * nodes[t].alpha / 255));
}
}
}
@@ -944,13 +890,7 @@ static void draw_under(void) {
/* a text node drawn as the engine does, in another colour */
static void draw_text(NodeId t, uint16_t color) {
if (!t || nodes[t].kind != NK_TEXT || nodes[t].ref == NONE16 || !node_visible_chain(t)) return;
- Mat mt = mat_mul((Mat){1.0f / 3, 0, 0, 1.0f / 3, 0, 0}, node_global(t));
- const uint8_t *pl = payload(nodes[t].ref);
- float scale = sqrtf(mt.a * mt.a + mt.b * mt.b), px = pl[2] * scale;
- int k = px >= 26 ? 3 : px >= 16 ? 2 : 1;
- int lw = (int)(rds16(pl + 8) * .25f * scale), lh = (int)(rds16(pl + 10) * .25f * scale);
- if (lh > 0 && lh < FONT_LINE * k) lh = FONT_LINE * k;
- gfx_text_k(node_text(t), mt, color, pl[6], (int16_t)lw, (int16_t)lh, nodes[t].alpha, k);
+ node_text_draw(t, mat_mul((Mat){1.0f / 3, 0, 0, 1.0f / 3, 0, 0}, node_global(t)), NULL, color, nodes[t].alpha);
}
/* Cba (the arrow meters): the white arrow (13 x 3 at (-6, -6)) under a mask
@@ -988,7 +928,6 @@ static void draw_over(void) {
}
draw_arrow_ui(S->arrow_ui, S->arrow_f);
draw_arrow_ui(S->carrow_ui, S->carrow_f);
- banner_draw();
}
/* the engine's pass draws the HUD without the two time texts (drawn above) */
diff --git a/games/championisland/src/sport_climbing.c b/games/championisland/src/sport_climbing.c
index 7e9e3ca9..f41adef2 100644
--- a/games/championisland/src/sport_climbing.c
+++ b/games/championisland/src/sport_climbing.c
@@ -943,12 +943,12 @@ static void sys_end(void) {
if (!g) return;
Ent *v = cl_vel();
if (S->has_goal && inside(S->goal, rawx(g), rawy(g))) {
- toast(msg("YOU_WIN"));
+ toast_style(msg("YOU_WIN"), 80, 0x222222, -1);
finish(altitude_of(rawy(g)), 3);
S->moving = false;
if (v) v->vx = v->vy = 0;
} else if (S->KY < 0) {
- toast(msg("TIMES_UP"));
+ toast_style(msg("TIMES_UP"), 80, 0x222222, -1);
int b = altitude_of(rawy(g));
finish(b, b > 60 ? 2 : b > 30 ? 1 : 0);
S->moving = false;
diff --git a/games/championisland/src/sport_marathon.c b/games/championisland/src/sport_marathon.c
index 75f59122..08fb990a 100644
--- a/games/championisland/src/sport_marathon.c
+++ b/games/championisland/src/sport_marathon.c
@@ -70,9 +70,7 @@ typedef struct {
/* flow */
Countdown cd;
bool started, ended, finish_shown;
- int end_t, rating, banner_t;
- const char *banner;
- uint16_t banner_color, banner_outline;
+ int end_t, rating;
uint32_t score;
char time_buf[16], speed_buf[32], dist_buf[24], place_buf[OPP_MAX + 1][12];
uint16_t place_color[OPP_MAX + 1];
@@ -644,13 +642,6 @@ static void hud(void) {
}
/* ---------------------------------------------------------------- the finish (as) */
-static void banner(const char *s, uint16_t color, uint16_t outline) { /* To */
- S->banner = s;
- S->banner_color = color;
- S->banner_outline = outline;
- S->banner_t = 1;
-}
-
static void finish(void) {
if (S->ended) {
if (S->end_t > 0 && --S->end_t == 0) menus_game_over_rated((float)S->score, S->rating);
@@ -670,10 +661,10 @@ static void finish(void) {
o->vy = 0;
if (pos_x(o->n) > bx) m++;
}
- if (m == 0) banner(msg("FIRST_PLACE"), rgb565(0xff, 0xde, 0x38), rgb565(0xa1, 0x87, 0x22));
- else if (m == 1) banner(msg("SECOND_PLACE"), rgb565(0xa1, 0xa4, 0xa6), rgb565(0x5f, 0x62, 0x63));
- else if (m == 2) banner(msg("THIRD_PLACE"), rgb565(0xb5, 0x86, 0x57), rgb565(0x6b, 0x4a, 0x29));
- else banner(msg("FINISH"), rgb565(0xff, 0xff, 0xff), rgb565(0x55, 0x55, 0x55));
+ if (m == 0) toast_full(msg("FIRST_PLACE"), 80, 0x111111, 0xa18722, 0xffde38);
+ else if (m == 1) toast_full(msg("SECOND_PLACE"), 80, 0x111111, 0x5f6263, 0xa1a4a6);
+ else if (m == 2) toast_full(msg("THIRD_PLACE"), 80, 0x111111, 0x6b4a29, 0xb58657);
+ else toast(msg("FINISH"));
S->ended = true;
S->end_t = END_DELAY;
S->score = S->tick;
@@ -709,7 +700,6 @@ static void tick(void) {
ephemeral_in(S->map); /* Vp */
if (S->player) ephemeral_in(S->player);
sort_draw(); /* Pp */
- if (S->banner_t > 0) S->banner_t++;
}
/* ---------------------------------------------------------------- drawing */
@@ -747,47 +737,15 @@ static void draw_text_as(NodeId t, const char *s, uint16_t color) {
uint8_t alpha = 255;
for (NodeId p = t; p; p = nodes[p].parent) alpha = (uint8_t)((alpha * nodes[p].alpha + 127) / 255);
if (!alpha) return;
- Mat m = mat_mul((Mat){1.0f / 3, 0, 0, 1.0f / 3, 0, 0}, node_global(t));
- const uint8_t *p = payload(nodes[t].ref);
- float scale = sqrtf(m.a * m.a + m.b * m.b), px = p[2] * scale;
- int k = px >= 26 ? 3 : px >= 16 ? 2 : 1;
- int lh = (int)(rds16(p + 10) * 0.25f * scale);
- /* one word: CreateJS only wraps at spaces */
- gfx_text_k(s, m, color, p[6], 0, (int16_t)lh, alpha, k);
+ node_text_draw(t, mat_mul((Mat){1.0f / 3, 0, 0, 1.0f / 3, 0, 0}, node_global(t)), s, color, alpha);
}
-static float cubic_out(float t) { return 1 - (1 - t) * (1 - t) * (1 - t); }
-
static void draw_over(void) {
if (!S || !S->map) return;
/* the placement bar's texts */
if (S->placement && nodes[S->placement].alpha) {
for (int f = 0; f < S->nplace; f++) draw_text_as(S->place_text[f], S->place_buf[f], S->place_color[f]);
}
- /* To: the banner slides in from the right, stays two seconds, leaves to the left */
- if (S->banner_t > 0 && S->banner) {
- int t = S->banner_t - 1;
- float dx;
- if (t < 12) dx = 1000 * (1 - cubic_out(t / 12.0f));
- else if (t < 72) dx = 0;
- else if (t < 81) { float q = (t - 72) / 9.0f; dx = -1000 * q * q * q; }
- else return;
- Mat m = MAT_ID;
- m.tx = (480 + dx) / 3;
- m.ty = (151.2f - 40) / 3;
- Mat s = m;
- s.ty += 80.0f / 12 / 3;
- gfx_text_k(S->banner, s, rgb565(0x11, 0x11, 0x11), 1, 0, 0, 204, 3);
- for (int oy = -1; oy <= 1; oy++)
- for (int ox = -1; ox <= 1; ox++) {
- if (!ox && !oy) continue;
- Mat o = m;
- o.tx += ox;
- o.ty += oy;
- gfx_text_k(S->banner, o, S->banner_outline, 1, 0, 0, 255, 3);
- }
- gfx_text_k(S->banner, m, S->banner_color, 1, 0, 0, 255, 3);
- }
}
static void end(void) {
diff --git a/games/championisland/src/sport_pingpong.c b/games/championisland/src/sport_pingpong.c
index aa55a129..5d2df90b 100644
--- a/games/championisland/src/sport_pingpong.c
+++ b/games/championisland/src/sport_pingpong.c
@@ -53,15 +53,6 @@ typedef struct {
typedef struct { float x, y; uint8_t kind, age; } Part;
-typedef struct {
- const char *text;
- int t, hold;
- uint8_t k;
- float dy;
- uint16_t shadow, outline;
- bool on;
-} Banner;
-
typedef struct {
NodeId root, map, ui, player, enemy, table, court, ptarget, etarget, ebounds, superbg;
NodeId t_wp, t_eu, t_score, meter, pprog, eprog, plabel;
@@ -93,7 +84,6 @@ typedef struct {
int last_meter, last_pprog, last_eprog, meter_f;
Part parts[PART_MAX];
int nparts;
- Banner banner;
char s_wp[16], s_eu[16], s_score[16];
} State;
@@ -309,47 +299,6 @@ static NodeId spawn(uint16_t sym, float x, float y) {
return e;
}
-/* ---------------------------------------------------------------- the banner (To) */
-static void banner(const char *text, int size, uint16_t shadow, uint16_t outline) {
- Banner *b = &S->banner;
- b->text = text;
- b->t = 0;
- b->hold = 60; /* 2000 ms */
- b->k = size >= 26 * 3 ? 3 : 2;
- b->dy = size / 3.0f / 12; /* the shadow sits c/12 lower */
- b->shadow = shadow;
- b->outline = outline;
- b->on = true;
-}
-
-static void banner_draw(void) {
- Banner *b = &S->banner;
- if (!b->on || !b->text) return;
- /* in from the right in 400 ms (cubicOut), out to the left in 300 ms (cubicIn) */
- float off;
- int t = b->t;
- if (t < 12) { float u = 1 - t / 12.0f; off = 1000 / 3.0f * u * u * u; }
- else if (t < 12 + b->hold) off = 0;
- else { float u = (t - 12 - b->hold) / 9.0f; off = -1000 / 3.0f * u * u * u; }
- if (t >= 12 + b->hold + 9) { b->on = false; return; }
- int h = FONT_HEIGHT * b->k;
- Mat m = MAT_ID;
- m.tx = floorf(160 + off);
- m.ty = floorf(540 * .28f / 3 - h / 2.0f + .5f);
- Mat s = m;
- s.ty += floorf(b->dy + .5f);
- gfx_text_k(b->text, s, b->shadow, 1, 0, 0, 204, b->k);
- static const int8_t o[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
- for (int i = 0; i < 4; i++) {
- Mat q = m;
- q.tx += o[i][0];
- q.ty += o[i][1];
- gfx_text_k(b->text, q, b->outline, 1, 0, 0, 255, b->k);
- }
- gfx_text_k(b->text, m, rgb565(255, 255, 255), 1, 0, 0, 255, b->k);
- b->t++;
-}
-
/* ---------------------------------------------------------------- balls */
static Ball *ball_of(NodeId n) {
for (int i = 0; i < S->nballs; i++)
@@ -688,16 +637,16 @@ static void end_of_game(void) {
return;
}
if (S->over || !(S->wp >= S->dJ || S->eu >= S->dJ)) return;
- uint16_t sh = rgb565(0x11, 0x11, 0x11), ol = rgb565(0x55, 0x55, 0x55);
+ int32_t sh = 0x111111, ol = 0x555555;
if (S->tutorial) {
- banner(msg(S->wp > S->eu ? "YOU_WIN" : "YOU_LOSE"), 80, sh, ol);
+ toast_style(msg(S->wp > S->eu ? "YOU_WIN" : "YOU_LOSE"), 80, sh, ol);
store_set_bool("TUTORIAL_DONE", true);
S->score = 1;
S->rating = 3;
} else {
S->rating = S->wp >= 30 ? 3 : S->wp >= 20 ? 2 : S->wp >= 10 ? 1 : 0;
S->score = 100.0f * (S->wp + (S->wp > S->eu ? S->wp - S->eu : 0));
- banner(msg(S->wp > S->eu ? "YOU_WIN" : "TENGU_WINS"), 80, sh, ol);
+ toast_style(msg(S->wp > S->eu ? "YOU_WIN" : "TENGU_WINS"), 80, sh, ol);
}
SOUND(end);
S->over = true;
@@ -902,11 +851,11 @@ static void start(void) {
/* ---------------------------------------------------------------- the systems */
static void countdown(void) { /* Wo */
if (!S->counting) return;
- uint16_t sh = rgb565(0x22, 0x22, 0x22), ol = rgb565(0xaa, 0xaa, 0xaa);
- if (S->cd == 90) { banner("3", 100, sh, ol); SOUND(beep); }
- else if (S->cd == 60) { banner("2", 100, sh, ol); SOUND(beep); }
- else if (S->cd == 30) { banner("1", 100, sh, ol); SOUND(beep); }
- else if (S->cd == 0) { banner(msg("GO"), 100, sh, ol); SOUND(go); S->counting = false; }
+ int32_t sh = 0x222222, ol = 0xaaaaaa;
+ if (S->cd == 90) { toast_style("3", 100, sh, ol); SOUND(beep); }
+ else if (S->cd == 60) { toast_style("2", 100, sh, ol); SOUND(beep); }
+ else if (S->cd == 30) { toast_style("1", 100, sh, ol); SOUND(beep); }
+ else if (S->cd == 0) { toast_style(msg("GO"), 100, sh, ol); SOUND(go); S->counting = false; }
if (S->cd > 0) S->cd--;
}
@@ -1036,13 +985,8 @@ static void draw_popup(NodeId f, Mat parent) {
for (NodeId t = nodes[a].first; t; t = nodes[t].next) {
if (nodes[t].kind != NK_TEXT || !node_visible(t) || nodes[t].ref == NONE16) continue;
Mat mt = mat_mul(ma, node_local(t));
- const uint8_t *pl = payload(nodes[t].ref);
const char *s = node_text(t);
- float scale = sqrtf(mt.a * mt.a + mt.b * mt.b), px = pl[2] * scale;
- int k = px >= 26 ? 3 : px >= 16 ? 2 : 1;
- int lw = (int)(rds16(pl + 8) * .25f * scale);
- uint16_t col = s[0] == '-' ? rgb565(0xff, 0x33, 0x33) : rgb565(0xff, 0xff, 0xff);
- gfx_text_k(s, mt, col, pl[6], (int16_t)lw, 0, (uint8_t)(al * nodes[t].alpha / 255), k);
+ node_text_draw(t, mt, s, s[0] == '-' ? 0xF986 : 0xFFFF, (uint8_t)(al * nodes[t].alpha / 255)); /* #ff3333, #fff */
}
}
}
@@ -1092,7 +1036,6 @@ static void draw_over(void) {
if (!S) return;
if (S->map) nodes[S->map].flags |= NF_VISIBLE;
if (S->map) draw_meter();
- banner_draw();
}
static void end(void) {
diff --git a/games/championisland/src/sport_rugby.c b/games/championisland/src/sport_rugby.c
index 511680a8..e92bd5ed 100644
--- a/games/championisland/src/sport_rugby.c
+++ b/games/championisland/src/sport_rugby.c
@@ -96,9 +96,8 @@ typedef struct {
/* flow */
Countdown cd;
bool started, ended;
- int tile_t, end_t, win_t, rating, toast_t;
+ int tile_t, end_t, win_t, rating;
uint32_t vis_t;
- const char *toast_s;
char score_buf[16], dist_buf[32];
} State;
@@ -1272,11 +1271,6 @@ static bool in_end_zone(void) {
return false;
}
-static void big_toast(const char *s) { /* To(..., {size: 100, shadow: "#222", outline: "#aaa"}) */
- S->toast_s = s;
- S->toast_t = 1;
-}
-
static void finish(int rating) {
S->ended = true;
S->end_t = END_DELAY;
@@ -1285,7 +1279,6 @@ static void finish(int rating) {
}
static void the_end(bool zone) {
- if (S->toast_t > 0) S->toast_t++;
if (S->ended) {
if (S->win_t > 0 && --S->win_t == 0 && S->pl >= 0) act_label(&S->act[S->pl], "win");
if (S->end_t > 0 && --S->end_t == 0) menus_game_over_rated((float)S->score, S->rating);
@@ -1294,7 +1287,7 @@ static void the_end(bool zone) {
if (S->pl < 0) return;
Actor *g = &S->act[S->pl];
if (S->tackled) {
- big_toast(msg("ONIS_WIN"));
+ toast_countdown(msg("ONIS_WIN"));
finish(-1);
for (int i = 0; i < S->nact; i++) {
Actor *a = &S->act[i];
@@ -1315,7 +1308,7 @@ static void the_end(bool zone) {
if (S->act[i].kind == A_CHAR && (S->act[i].flags & AF_ALLY)) act_label(&S->act[i], "idle");
finish(3);
SOUND(e_a);
- big_toast(msg("YOU_WIN"));
+ toast_countdown(msg("YOU_WIN"));
}
}
@@ -1441,34 +1434,6 @@ static void draw_under(void) {
}
}
-/* To: the banner slides in from the right (400 ms), stays 2 s, leaves to the left (300 ms) */
-static float cubic_out(float t) { return 1 - (1 - t) * (1 - t) * (1 - t); }
-
-static void draw_over(void) {
- if (!S || S->toast_t <= 0 || !S->toast_s) return;
- int t = S->toast_t - 1;
- float dx;
- if (t < 12) dx = 1000 * (1 - cubic_out(t / 12.0f));
- else if (t < 72) dx = 0;
- else if (t < 81) { float q = (t - 72) / 9.0f; dx = -1000 * q * q * q; }
- else return;
- Mat m = MAT_ID;
- m.tx = (480 + dx) / 3;
- m.ty = (151.2f - 50) / 3;
- Mat sh = m;
- sh.ty += 100.0f / 12 / 3;
- gfx_text_k(S->toast_s, sh, rgb565(0x22, 0x22, 0x22), 1, 0, 0, 204, 3);
- for (int oy = -1; oy <= 1; oy++)
- for (int ox = -1; ox <= 1; ox++) {
- if (!ox && !oy) continue;
- Mat o = m;
- o.tx += ox;
- o.ty += oy;
- gfx_text_k(S->toast_s, o, rgb565(0xaa, 0xaa, 0xaa), 1, 0, 0, 255, 3);
- }
- gfx_text_k(S->toast_s, m, rgb565(0xff, 0xff, 0xff), 1, 0, 0, 255, 3);
-}
-
static void end(void) {
if (S)
for (int i = 0; i < S->nproto; i++) node_free(S->proto[i]); /* not in the scene's tree */
@@ -1476,4 +1441,4 @@ static void end(void) {
S = NULL;
}
-const SceneDef scene_rugby = {"rugby", start, tick, end, draw_under, draw_over, NULL};
+const SceneDef scene_rugby = {"rugby", start, tick, end, draw_under, NULL, NULL};
diff --git a/games/championisland/src/sport_skate.c b/games/championisland/src/sport_skate.c
index 1bb16fe5..deb7f5f7 100644
--- a/games/championisland/src/sport_skate.c
+++ b/games/championisland/src/sport_skate.c
@@ -1841,14 +1841,7 @@ static void draw_under(void) {
/* a HUD text in a colour of the code's (the time's red, a fall's red) */
static void text_in(NodeId n, uint16_t color) {
if (!n || nodes[n].kind != NK_TEXT || nodes[n].ref == NONE16 || !nodes[n].alpha) return;
- Mat m = mat_mul((Mat){1.0f / 3, 0, 0, 1.0f / 3, 0, 0}, node_global(n));
- const uint8_t *t = payload(nodes[n].ref);
- float scale = sqrtf(m.a * m.a + m.b * m.b), px = t[2] * scale;
- int k = px >= 26 ? 3 : px >= 16 ? 2 : 1;
- int lw = (int)(rds16(t + 8) * 0.25f * scale), lh = (int)(rds16(t + 10) * 0.25f * scale);
- if (lh > 0 && lh < FONT_LINE * k) lh = FONT_LINE * k;
- m.ty += t[7] == 1 ? -5 * k : t[7] >= 2 ? -9 * k : 0;
- gfx_text_k(node_text(n), m, color, t[6], (int16_t)lw, (int16_t)lh, nodes[n].alpha, k);
+ node_text_draw(n, mat_mul((Mat){1.0f / 3, 0, 0, 1.0f / 3, 0, 0}, node_global(n)), NULL, color, nodes[n].alpha);
}
/* a sprite as a shape of one colour (the icons tinted green): a rectangle per run of pixels, built in
diff --git a/games/championisland/src/sport_swim.c b/games/championisland/src/sport_swim.c
index 6a675566..2e31405a 100644
--- a/games/championisland/src/sport_swim.c
+++ b/games/championisland/src/sport_swim.c
@@ -488,10 +488,10 @@ static void draw_over(void) {
float alpha = ms <= 700 ? 1 : ms >= 1000 ? 0 : 1 - (ms - 700) / 300;
if (alpha <= 0) return;
const char *s = msg(keys[S->judge]);
- int k = 40.0f / 3 * sc >= 17 ? 2 : 1;
+ int k3 = (int)(40 * sc / 10 + .5f); /* 40 px on the stage, scaled: in thirds of the font's 10 px */
Mat m = MAT_ID;
m.tx = VIEW_W / 2;
- m.ty = 540 * .28f / 3 - 5.5f * k;
+ m.ty = floorf((540 * .28f - 20 * sc) / 3 + .5f) - k3 / 3;
uint8_t a = (uint8_t)(alpha * 255);
uint16_t fg = rgb565(col[S->judge][0], col[S->judge][1], col[S->judge][2]);
uint16_t ol = rgb565(col[S->judge][3], col[S->judge][4], col[S->judge][5]);
@@ -500,9 +500,9 @@ static void draw_over(void) {
Mat o = m;
o.tx += off[i][0];
o.ty += off[i][1];
- gfx_text_k(s, o, ol, 1, 0, 0, a, k);
+ gfx_text_k3(s, o, ol, 1, 0, 0, a, k3);
}
- gfx_text_k(s, m, fg, 1, 0, 0, a, k);
+ gfx_text_k3(s, m, fg, 1, 0, 0, a, k3);
}
const SceneDef scene_swim = {"swim", start, tick, end, NULL, draw_over, NULL};
diff --git a/games/championisland/tools/pack.py b/games/championisland/tools/pack.py
index 3a19aa72..ae24592f 100644
--- a/games/championisland/tools/pack.py
+++ b/games/championisland/tools/pack.py
@@ -734,6 +734,54 @@ def child_name(c):
return nm or pk
+SLOT_CONFLICTS = []
+
+
+def slot_order(slots, frames):
+ """The children's stacking order over all frames: each frame's own order
+ (a child that shows up later, such as a button's focus background, still
+ goes under the ones it is drawn under), as a topological sort; where two
+ frames disagree the first one wins. Ties: where a child first stands."""
+ first = {i: min((v[0], fi) for fi, v in enumerate(slots[i]) if v is not None) for i in slots}
+ succ = {i: set() for i in slots}
+
+ def reaches(a, b):
+ todo, seen = [a], set()
+ while todo:
+ x = todo.pop()
+ if x == b:
+ return True
+ if x not in seen:
+ seen.add(x)
+ todo.extend(succ[x])
+ return False
+
+ for fr in frames:
+ order = [c['i'] for c in fr]
+ for a, b in zip(order, order[1:]):
+ if a == b or b in succ[a]:
+ continue
+ if reaches(b, a):
+ SLOT_CONFLICTS.append((a, b))
+ continue
+ succ[a].add(b)
+ indeg = {i: 0 for i in slots}
+ for a in slots:
+ for b in succ[a]:
+ indeg[b] += 1
+ ready = sorted((first[i], i) for i in slots if not indeg[i])
+ out = []
+ while ready:
+ _, x = ready.pop(0)
+ out.append(x)
+ for b in succ[x]:
+ indeg[b] -= 1
+ if not indeg[b]:
+ ready.append((first[b], b))
+ ready.sort()
+ return out
+
+
def child_state(lib, c):
"""What a child slot shows at a frame, as a hashable tuple."""
tr = c['tr']
@@ -890,8 +938,7 @@ for (lib, k) in SYMS:
for fi, fr in enumerate(frames):
for depth, c in enumerate(fr):
slots[c['i']][fi] = (depth, child_state(lib, c))
- # children keep the stacking order they first appear in (Animate keeps layer order)
- slot_ids = sorted(slots, key=lambda i: min((v[0], fi) for fi, v in enumerate(slots[i]) if v is not None))
+ slot_ids = slot_order(slots, frames)
body = bytearray()
for i in slot_ids:
keys, prev = [], 'x'
@@ -1467,6 +1514,8 @@ tot_streams = sum(v[1] for v in stream_off.values())
print('symbols %d, sprites %d (%d banks %d KB, %d streams %d KB), mats %d, strings %d, exprs %d, dialog nodes %d, vars %d' % (
len(SYMS), len(SPR), len(banks), tot_banks // 1024, len(streams), tot_streams // 1024, len(MATS), len(strings), len(EXPRS), len(dlg_index), len(VARS)))
print({k: v // 1024 for k, v in STATS.items()})
+if SLOT_CONFLICTS:
+ print('clips whose frames disagree on stacking: %d pairs' % len(SLOT_CONFLICTS))
print('data.bin: %d KB (strings %d KB)' % (len(final) // 1024, len(str_data) // 1024))
if os.environ.get('PACK_STATS'):
diff --git a/games/championisland/tools/ref.js b/games/championisland/tools/ref.js
index 43150e1b..b45df8cd 100644
--- a/games/championisland/tools/ref.js
+++ b/games/championisland/tools/ref.js
@@ -11,6 +11,7 @@
// big name save OUT/name.png (960x540)
// eval js run JavaScript in the page
// store K V set the game's saved value K (JSON V) before it starts
+// click X Y click the page at stage pixel (X, Y) of 960 x 540
const http = require('http');
const fs = require('fs');
const path = require('path');