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
Champion Island: clips run their first frame's script, off-stage clips rest, texts default to black
Mason Chenef0fe3997287
diff --git a/games/championisland/src/node.c b/games/championisland/src/node.cindex 9d4c78c3..60af4008 100644--- a/games/championisland/src/node.c+++ b/games/championisland/src/node.c@@ -42,6 +42,7 @@ static NodeId alloc_node(void) {free_head = nodes[n].next;memset(&nodes[n], 0, sizeof nodes[n]);nodes[n].flags = NF_USED | NF_VISIBLE | NF_ONSTAGE | NF_PLAYING | NF_TICK;+ nodes[n].flags2 = NF2_FRESH;nodes[n].alpha = 255;nodes[n].sym = NONE16;nodes[n].slot = NONE16;@@ -419,6 +420,7 @@ bool node_goto(NodeId n, const char *label, int frame, bool play) {if (frame >= c.nframes) frame = c.nframes - 1;if (frame < 0) frame = 0;nodes[n].frame = (uint16_t)frame;+ nodes[n].flags2 &= (uint8_t)~NF2_FRESH;if (play) nodes[n].flags |= NF_PLAYING; else nodes[n].flags &= (uint8_t)~NF_PLAYING;run_actions(n, (unsigned)frame);return true;@@ -441,7 +443,18 @@ const char *node_label(NodeId n) {/* The Ticker: every playing independent clip moves on one frame. */static void tick_rec(NodeId n) {Node *p = &nodes[n];- if (!(p->flags & NF_TICK)) return;+ /* CreateJS ticks what is on the display list: a timeline child that is not+ * on stage at its parent's frame is out of it */+ if (!(p->flags & NF_TICK) || !(p->flags & NF_ONSTAGE)) return;+ if (p->flags2 & NF2_FRESH) {+ /* a new clip's first tick puts it at its frame and runs that frame's script (a stop there holds it) */+ p->flags2 &= (uint8_t)~NF2_FRESH;+ if (p->kind == NK_CLIP && node_mode(p) == MODE_INDEPENDENT) {+ run_actions(n, p->frame);+ for (NodeId ch = nodes[n].first; ch; ch = nodes[ch].next) tick_rec(ch);+ return;+ }+ }if (p->kind == NK_CLIP && node_mode(p) == MODE_INDEPENDENT && (p->flags & NF_PLAYING)) {Clip c;if (clip_get(p->sym, &c) && c.nframes > 1) {@@ -508,6 +521,7 @@ static void update_rec(NodeId n) {if (!was && node_mode(&nodes[ch]) == MODE_INDEPENDENT && nodes[ch].kind == NK_CLIP) {nodes[ch].frame = 0; /* re-entering the stage restarts it, as Animate does */nodes[ch].flags |= NF_PLAYING;+ nodes[ch].flags2 |= NF2_FRESH;}}if (node_mode(&nodes[ch]) == MODE_SYNCHED && idx != NONE16) {diff --git a/games/championisland/src/node.h b/games/championisland/src/node.hindex 6c0aca0b..5308c1af 100644--- a/games/championisland/src/node.h+++ b/games/championisland/src/node.h@@ -41,7 +41,7 @@ typedef struct {uint8_t kind, flags, flags2, alpha;} Node;/* flags2: how its parent's timeline drives it, streaming */-enum { NF2_LAZY = 1, NF2_KEEP = 2, NF2_NOLOOP = 4, NF2_MODE = 24 /* mode << 3 */, NF2_DYN = 32 };+enum { NF2_LAZY = 1, NF2_KEEP = 2, NF2_NOLOOP = 4, NF2_MODE = 24 /* mode << 3 */, NF2_DYN = 32, NF2_FRESH = 64 /* its first tick is to come */ };static inline uint8_t node_mode(const Node *n) { return (uint8_t)((n->flags2 & NF2_MODE) >> 3); }static inline bool node_loops(const Node *n) { return !(n->flags2 & NF2_NOLOOP); }diff --git a/games/championisland/tools/pack.py b/games/championisland/tools/pack.pyindex bd0293be..8a8b047c 100644--- a/games/championisland/tools/pack.py+++ b/games/championisland/tools/pack.py@@ -307,7 +307,7 @@ def enc_text(c):font = c.get('font') or ''m = re.search(r'(\d+(?:\.\d+)?)px', font)size = int(round(float(m.group(1)))) if m else 10- col = parse_color(c.get('color')) or (255, 255, 255, 255)+ col = parse_color(c.get('color')) or (0, 0, 0, 255) # CreateJS draws texts without a colour blackalign = {'left': 0, 'start': 0, 'center': 1, 'right': 2, 'end': 2}.get(c.get('align') or 'left', 0)base = {'top': 0, 'hanging': 0, 'middle': 1, 'alphabetic': 2, 'ideographic': 2, 'bottom': 3}.get(c.get('base') or 'top', 0)return struct.pack('<HBBBBBBhh', sid(c.get('text') or ''), size, col[0], col[1], col[2], align, base,