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
Among Us: the kill finishes before a report, the target outlined, How to Play first
Mason3637d7789906997
diff --git a/games/amongus/src/game.c b/games/amongus/src/game.cindex b36cba06..4aac474a 100644--- a/games/amongus/src/game.c+++ b/games/amongus/src/game.c@@ -297,8 +297,11 @@ int living(bool imp) {return n;}+void game_counted(bool won, bool imp);+static void end_game(int winner, int reason) {if (g.screen == S_END) return;+ game_counted((winner == 1) == (g.p[g.me].imp != 0), g.p[g.me].imp);g.winner = (uint8_t)winner;g.end_reason = (uint8_t)reason;g.screen = S_END;@@ -352,6 +355,11 @@ void kill_player(int killer, int victim) {void start_meeting(int caller, int body) {if (g.screen == S_END) return;+ if (g.screen == S_KILLED) {+ /* the player's kill plays to its end first */+ if (!g.meet_pending) g.meet_pending = 1, g.caller = (uint8_t)caller, g.reported = (uint8_t)body;+ return;+ }g.caller = (uint8_t)caller;g.reported = (uint8_t)body; /* the dead player's number, or NONE for the button */if (body == NONE) g.p[caller].emergencies--;@@ -554,6 +562,15 @@ static void write_copy(uint32_t glen, const SetFile *s) {SetFile set_file;+/* the first game: How to Play comes first */+bool first_play(void) { return set_file.games == 0; }+/* the player's games and wins (Statistics) */+void game_counted(bool won, bool imp) {+ if (set_file.games < 0xFFFF) set_file.games++;+ if (won && imp && set_file.wins_imp < 0xFFFF) set_file.wins_imp++;+ if (won && !imp && set_file.wins_crew < 0xFFFF) set_file.wins_crew++;+}+static void settings_defaults(void) {Options *o = &g.opt;o->bots = 7, o->impostors = 1, o->role = 0, o->color = 0;diff --git a/games/amongus/src/game.h b/games/amongus/src/game.hindex 3182c7b3..1cb85c93 100644--- a/games/amongus/src/game.h+++ b/games/amongus/src/game.h@@ -113,7 +113,7 @@ typedef struct {V2 cam;uint8_t killer, kill_anim, task_open, mg_cons;float kill_t;- uint8_t room_shown, pad1[3];+ uint8_t room_shown, meet_pending, pad1[2]; /* meet_pending: a meeting called during the player's kill */float room_t;float task_bar; /* shown (it updates only in meetings when set so) */uint8_t mg[512]; /* the open minigame's own state */diff --git a/games/amongus/src/gfx.c b/games/amongus/src/gfx.cindex ed530837..9f0a052b 100644--- a/games/amongus/src/gfx.c+++ b/games/amongus/src/gfx.c@@ -83,9 +83,11 @@ void gfx_spr(const Pic *p, int x, int y, bool flip, const uint16_t *pal, int alpgfx_spr_clip(p, x, y, flip, pal, alpha, 0, 0, SCREEN_W, SCREEN_H);}-void gfx_spr_tint(const Pic *p, int x, int y, uint16_t col, int alpha) {+void gfx_spr_tint(const Pic *p, int x, int y, uint16_t col, int alpha) { gfx_spr_tint_flip(p, x, y, false, col, alpha); }++void gfx_spr_tint_flip(const Pic *p, int x, int y, bool flip, uint16_t col, int alpha) {if (!p) return;- int x0 = x - p->ox, y0 = y - p->oy;+ int x0 = x - (flip ? p->w - p->ox : p->ox), y0 = y - p->oy;if (!gfx_rows(y0, y0 + p->h)) return;const uint8_t *al = p->flags & P_MIX ? gfx_mix_alpha : pic_alpha(p);int astep = (p->flags & P_MIX) ? 4 : 1;@@ -97,7 +99,7 @@ void gfx_spr_tint(const Pic *p, int x, int y, uint16_t col, int alpha) {for (int c = 0; c < p->w; c++) {int xx = x0 + c;if ((unsigned)xx >= SCREEN_W) continue;- unsigned a = al[px_at(p, px, c, r) * astep];+ unsigned a = al[px_at(p, px, flip ? p->w - 1 - c : c, r) * astep];if (a > 128) row[xx] = blend(row[xx], col, alpha);}}diff --git a/games/amongus/src/gfx.h b/games/amongus/src/gfx.hindex 49f2ea3a..38a45461 100644--- a/games/amongus/src/gfx.h+++ b/games/amongus/src/gfx.h@@ -42,6 +42,7 @@ void gfx_spr_clip(const Pic *p, int x, int y, bool flip, const uint16_t *pal, invoid gfx_pic(const Pic *p, float x, float y, float sx, float sy, float angle, const uint16_t *pal, int alpha);/* a picture tinted by c (alpha kept): the outlines of usable consoles */void gfx_spr_tint(const Pic *p, int x, int y, uint16_t c, int alpha);+void gfx_spr_tint_flip(const Pic *p, int x, int y, bool flip, uint16_t c, int alpha);/* a tiled picture with its pivot at (x, y) */void gfx_tiles(const TilePic *s, int x, int y);void gfx_fill(int x, int y, int w, int h, uint16_t c, int alpha);diff --git a/games/amongus/src/main.c b/games/amongus/src/main.cindex 6e228aa3..25475604 100644--- a/games/amongus/src/main.c+++ b/games/amongus/src/main.c@@ -12,14 +12,44 @@ const uint32_t eadk_api_level __attribute__((section(".rodata.eadk_api_level")))uint32_t perf_frames __attribute__((used)); /* read by tools/emu.py */uint32_t perf_max __attribute__((used));+uint32_t perf_slow __attribute__((used)); /* frames over 33 ms */extern bool game_running;+#ifdef PERF_SCENE+/* (measuring builds only: make EXTRA=-DPERF_SCENE=n starts a round in a scene) */+#include "mg.h"+#include "world.h"+static void perf_scene(int n) {+ g.opt.role = n == 9 ? 2 : 1;+ game_new();+ g.screen = S_PLAY;+ int imp = 1;+ while (!g.p[imp].imp) imp++;+ for (int k = 0; k < 90; k++) game_tick(0);+ switch (n) {+ case 1: kill_player(imp, 0); break;+ case 2: kill_player(imp, 2), start_meeting(0, 2); break;+ case 3: start_meeting(0, NONE), g.screen = S_MEETING, g.meet_t = 0; bot_meeting_start(); break;+ case 4: map_open(O_MAP); break;+ case 5: g.sab_cd = 0, sabotage(SAB_LIGHTS); break;+ case 6: for (int c = 0; c < N_CONSOLES; c++) if (CONSOLES[c].kind == 3) g.p[0].pos = (V2){CONSOLES[c].sx, CONSOLES[c].sy}, mg_open(c, MAX_TASKS); break;+ case 7: g.p[0].pos = (V2){-21.0f, -5.0f}; break; /* the reactor room */+ case 8: g.p[0].pos = (V2){-8.0f, -10.0f}; break; /* electrical */+ case 9: map_open(O_SABMAP); break;+ }+ g.cam = (V2){g.p[0].pos.x, g.p[0].pos.y + FEET_Y};+}+#endif+int main(void) {/* the band drawn into lives on main's stack */uint16_t band[SCREEN_W * BAND];gfx_init(band);plat_begin();game_init();+#ifdef PERF_SCENE+ perf_scene(PERF_SCENE);+#endif/* the game's fixed 30 ticks a second (TimeManager's Fixed Timestep), at most 3 a drawing */uint32_t next = plat_millis() * 3; /* in thirds of a millisecond: 100 a tick */while (game_running) {@@ -37,6 +67,7 @@ int main(void) {game_draw();uint32_t dt = plat_millis() - t0;if (dt > perf_max && perf_frames > 30) perf_max = dt;+ if (dt > 33 && perf_frames > 30) perf_slow++;perf_frames++;} else {plat_sleep(1);diff --git a/games/amongus/src/screens.c b/games/amongus/src/screens.cindex cc873398..b995f9f9 100644--- a/games/amongus/src/screens.c+++ b/games/amongus/src/screens.c@@ -14,6 +14,7 @@ static uint32_t last_keys;void play_tick(uint32_t keys, uint32_t pressed);void hud_keys(const char *s);void game_forget(void);+bool first_play(void);void view_prepare(void);void art_title(void);void art_kill(float t);@@ -159,7 +160,8 @@ static void title_tick(uint32_t pressed) {if (pressed & K_UP) g.sel = (uint8_t)((g.sel + 1) % 2);if (pressed & K_DOWN) g.sel = (uint8_t)((g.sel + 1) % 2);if (pressed & (K_OK | K_EXE)) {- if (g.sel == 0) g.screen = S_LOBBY, g.sel = N_OPT, lobby_top = N_OPT - 8;+ if (g.sel == 0 && first_play()) g.screen = S_HOWTO, g.back_screen = S_LOBBY, g.sel = 0;+ else if (g.sel == 0) g.screen = S_LOBBY, g.sel = N_OPT, lobby_top = N_OPT - 8;else g.screen = S_HOWTO, g.back_screen = S_TITLE, g.sel = 0;g.screen_t = 0;}@@ -190,12 +192,17 @@ static const char *const HOWTO[][6] = {};static void howto_tick(uint32_t pressed) {+ bool out = false;if (pressed & (K_RIGHT | K_OK | K_EXE)) {if (g.sel < 2) g.sel++;- else g.screen = g.back_screen, g.sel = 0;+ else out = true;}if ((pressed & K_LEFT) && g.sel) g.sel--;- if (pressed & K_BACK) g.screen = g.back_screen, g.sel = 0;+ if (pressed & K_BACK) out = true;+ if (out) {+ g.screen = g.back_screen, g.sel = 0;+ if (g.screen == S_LOBBY) g.sel = N_OPT, lobby_top = N_OPT - 8;+ }}static void howto_draw(void) {@@ -347,7 +354,10 @@ void game_tick(uint32_t keys) {case S_KILLED:/* the round goes on meanwhile */play_tick(0, 0);- if (g.screen == S_KILLED && g.screen_t > 2.6f) g.screen = S_PLAY, g.screen_t = 0;+ if (g.screen == S_KILLED && g.screen_t > 2.6f) {+ g.screen = S_PLAY, g.screen_t = 0;+ if (g.meet_pending) g.meet_pending = 0, start_meeting(g.caller, g.reported);+ }break;case S_REPORT:if (g.screen_t > 2.5f) {diff --git a/games/amongus/src/view.c b/games/amongus/src/view.cindex 666561e9..91bcb50a 100644--- a/games/amongus/src/view.c+++ b/games/amongus/src/view.c@@ -8,6 +8,7 @@#include "world.h"View view;+int kill_target(int i);/* ---- the camera: the ship's pixels at the screen's top-left ---- */@@ -137,6 +138,8 @@ void view_prepare(void) {}}nitems = 0;+ view.target = -1;+ if (M->imp && M->alive && M->kill_cd <= 0 && g.screen == S_PLAY) view.target = kill_target(g.me);/* doors */for (int d = 0; d < N_DOORS; d++) {const DoorRec *D = &DOORS[d];@@ -179,7 +182,12 @@ void view_prepare(void) {static void draw_items(void) {for (int k = 0; k < nitems; k++) {const Item *it = &items[k];- if (!gfx_rows(it->y0, it->y1)) continue;+ if (!gfx_rows(it->y0 - 1, it->y1 + 1)) continue;+ if (it->kind == D_PLAYER && it->i == view.target) {+ /* the impostor's target outlined in red (PlayerControl.SetOutline) */+ for (int d = 0; d < 4; d++)+ gfx_spr_tint_flip(it->pic, it->x + (d == 0) - (d == 1), it->y + (d == 2) - (d == 3), it->flip, 0xF800, 256);+ }gfx_spr(it->pic, it->x, it->y, it->flip, it->pal, it->alpha);if (it->kind == D_DOOR) continue;/* what stands in front of it, drawn again over it */diff --git a/games/amongus/src/view.h b/games/amongus/src/view.hindex c5f742ab..1d9f0a2c 100644--- a/games/amongus/src/view.h+++ b/games/amongus/src/view.h@@ -9,6 +9,7 @@ typedef struct {int cx, cy; /* the ship's pixel at the screen's top-left */float radius;bool dark;+ int target; /* the player the impostor would kill, outlined */int npts;float pts[2 * VIEW_MAXPTS]; /* the light's polygon, on the screen */} View;diff --git a/games/amongus/tests/check.py b/games/amongus/tests/check.pyindex e653fbb4..ffe0b28c 100644--- a/games/amongus/tests/check.py+++ b/games/amongus/tests/check.py@@ -69,7 +69,8 @@ for k, name in enumerate(NAMES):check(bool(ok), "minigame %s%s" % (name, " (frame %s)" % m.group(1) if m else ""))# whole games: through the menus to a crew win, an impostor's game to an impostor win-out = play("--auto", "--keys", "10:ok,20:ok", "--frames", 90000, "--seed", 3, "--walled")+# (the first Play shows How to Play's three pages, then the settings with Start chosen)+out = play("--auto", "--keys", "10:ok,20:ok,30:ok,40:ok,50:ok", "--frames", 90000, "--seed", 3, "--walled")check(end(out) and end(out)[:2] == (7, 0) and "WALLED" not in out, "a crew game from the title to a crew win: %s" % (end(out),))out = play("--start", "imp", "--auto", "--bots", 9, "--imps", 2, "--frames", 90000, "--seed", 2, "--walled")check(end(out) and end(out)[:2] == (7, 1) and "WALLED" not in out, "an impostor's game to an impostor win: %s" % (end(out),))@@ -121,7 +122,7 @@ else:check(True, "40 broken saves: no crash")# the settings keptsaves = os.path.join(WORK, "s2")-play("--frames", 60, "--keys", "10:ok,20:down,25:right,30:back", saves=saves)+play("--frames", 60, "--keys", "10:ok,20:back,30:down,35:right,40:back", saves=saves)out = play("--frames", 5, saves=saves, fresh=False)check("bots 8" in out, "a setting kept: %s" % re.search(r"bots \d+", out).group(0))diff --git a/games/amongus/tests/rules.c b/games/amongus/tests/rules.cindex c184e812..03b4f070 100644--- a/games/amongus/tests/rules.c+++ b/games/amongus/tests/rules.c@@ -105,6 +105,15 @@ int rules(void) {/* the ghost: faster, no light, tasks still count */CHECK(near(player_speed(victim), 3.0f), "ghosts at 3.0");+ /* a body reported while the player's kill plays: the meeting after it */+ round_of(7, 1, 1);+ imp = first(true, -1);+ kill_player(imp, 0);+ start_meeting(1, 0);+ CHECK(g.screen == S_KILLED && g.meet_pending, "the kill plays on");+ for (int k = 0; k < 90 && g.screen == S_KILLED; k++) game_tick(0);+ CHECK(g.screen == S_REPORT && g.caller == 1 && g.reported == 0, "then the report");+/* reports: within 3 units, not through a wall */round_of(7, 1, 1);victim = 1;