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
Cat Ninja: the tests go through every teleporter
Mason363d674c89db08b
diff --git a/games/catninja/Makefile b/games/catninja/Makefileindex 63ea054c..be7be0e7 100644--- a/games/catninja/Makefile+++ b/games/catninja/Makefile@@ -26,6 +26,7 @@ CFLAGS += -Os -Wall -Wextra -Wno-unused-parameter -fno-math-errnoCFLAGS += -fno-tree-loop-distribute-patterns -flto -fno-fat-lto-objects -fwhole-program -fvisibility=internalCFLAGS += -ffunction-sections -fdata-sectionsCFLAGS += $(if $(PERF_LEVEL),-DPERF_LEVEL=$(PERF_LEVEL)) # (make perf PERF_LEVEL=n: that level straight away)+CFLAGS += $(if $(PERF_TP),-DPERF_TP=$(PERF_TP)) # (PERF_TP=k: the cat on its teleporter k)LDFLAGS = -Wl,--relocatable -nostartfiles --specs=nano.specsLDFLAGS += -Wl,-e,main -Wl,-u,eadk_app_name -Wl,-u,eadk_app_icon -Wl,-u,eadk_api_levelLDFLAGS += -Wl,--gc-sections -flinker-output=nolto-reldiff --git a/games/catninja/src/game.c b/games/catninja/src/game.cindex 0c7e2ff7..978e670b 100644--- a/games/catninja/src/game.c+++ b/games/catninja/src/game.c@@ -1267,6 +1267,11 @@ void game_get_resume(int *lvl, int *x, int *y, int *rot) {}/* a level straight away, its start the checkpoint (the tests, and pictures) */+/* (tests) the level's teleporters: start and end tiles */+int game_debug_teleports(int out[16][4]) {+ for (int k = 0; k < n_tps; k++) out[k][0] = tps[k].sx, out[k][1] = tps[k].sy, out[k][2] = tps[k].ex, out[k][3] = tps[k].ey;+ return n_tps;+}void game_debug_goto(int lv) {level = lv;target_dir = 4, target_respawn = false;diff --git a/games/catninja/src/main.c b/games/catninja/src/main.cindex 20ce6124..bb49214d 100644--- a/games/catninja/src/main.c+++ b/games/catninja/src/main.c@@ -219,6 +219,12 @@ int main(void) {{extern void game_debug_goto(int lv);game_debug_goto(PERF_LEVEL), sv.flags |= 1;+#ifdef PERF_TP /* (and the cat on that teleporter of the level) */+ extern int game_debug_teleports(int out[16][4]);+ for (int i = 0; i < 30; i++) game_step();+ int t[16][4];+ if (game_debug_teleports(t) > PERF_TP) P.x = t[PERF_TP][0] * 20 + 10, P.y = t[PERF_TP][1] * 20 + 10, P.speedx = 0;+#endif}#endifif (!(sv.flags & 1)) ov = OV_HELP, help_back = OV_NONE, sv.flags |= 1;diff --git a/games/catninja/tests/play.c b/games/catninja/tests/play.cindex 59f5dd15..43c7aed2 100644--- a/games/catninja/tests/play.c+++ b/games/catninja/tests/play.c@@ -438,6 +438,33 @@ static void test_levels(void) {}}+/* every teleporter: the cat walks onto it and comes out at its end, the world drawn all the while */+static void test_teleports(void) {+ extern int game_debug_teleports(int out[16][4]);+ int n_all = 0;+ for (int lv = -1; lv < 30; lv++) {+ game_new();+ game_debug_goto(lv);+ steps(30);+ int t[16][4], n = game_debug_teleports(t);+ for (int k = 0; k < n; k++) {+ game_new();+ game_debug_goto(lv);+ steps(30);+ P.x = t[k][0] * 20 + 10, P.y = t[k][1] * 20 + 10, P.speedx = 0, P.gravity = 0;+ for (int f = 0; f < 240; f++) {+ game_step();+ draw_frame();+ gfx_render(scene, NULL, 0, 240);+ CHECK(level >= -1 && level < 30 && P.x == P.x && P.y == P.y, "level %d: teleporter %d: lost", lv + 1, k);+ }+ n_all++;+ }+ }+ CHECK(n_all > 0, "no teleporters");+ printf(" %d teleporters\n", n_all);+}+/* the whole app on random keys: pauses, menus, the How to play page, quitting and coming back */static uint32_t fuzz_keys(void) {static uint32_t k;@@ -539,6 +566,8 @@ int main(int argc, char **argv) {test_run();printf("every level, random keys\n");test_levels();+ printf("teleporters\n");+ test_teleports();printf("saves\n");test_saves();printf("the app, random keys\n");