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.

Pause menus in each game's own look; 2 Players' icon is Pong's court

Mason3632e4c3a92f460
diff --git a/games/invaders/src/main.c b/games/invaders/src/main.c
index f89eacbb..461e51a1 100644
--- a/games/invaders/src/main.c
+++ b/games/invaders/src/main.c
@@ -81,7 +81,7 @@ static const uint16_t art[][8] = {
};
enum { A_BOOM = 6, A_CANNON, A_WRECK, A_SAUCER = 10, A_SBOOM, A_SBOOM2, A_PBOOM, A_ABOOM, A_SHOT, A_BUNKER, A_CELL = 20, A_LETTER };
/* the arcade's letters, 5 columns of 7 pixels (the lowest bit on top) */
-static const char glyphs[] = "0123456789ABCDEGHILMNOPRSTVY<>-*=?";
+static const char glyphs[] = "0123456789ABCDEGHILMNOPRSTVY<>-*=?UQJF";
static const uint8_t font[][5] = {
{0x3E, 0x51, 0x49, 0x45, 0x3E}, {0x00, 0x42, 0x7F, 0x40, 0x00}, {0x62, 0x51, 0x49, 0x49, 0x46},
{0x22, 0x41, 0x49, 0x49, 0x36}, {0x18, 0x14, 0x12, 0x7F, 0x10}, {0x27, 0x45, 0x45, 0x45, 0x39},
@@ -94,7 +94,8 @@ static const uint8_t font[][5] = {
{0x26, 0x49, 0x49, 0x49, 0x32}, {0x01, 0x01, 0x7F, 0x01, 0x01}, {0x1F, 0x20, 0x40, 0x20, 0x1F},
{0x07, 0x08, 0x70, 0x08, 0x07}, {0x08, 0x14, 0x22, 0x41, 0x00}, {0x00, 0x41, 0x22, 0x14, 0x08},
{0x08, 0x08, 0x08, 0x08, 0x08}, {0x22, 0x14, 0x7F, 0x14, 0x22}, {0x14, 0x14, 0x14, 0x14, 0x14},
- {0x02, 0x01, 0x51, 0x09, 0x06},
+ {0x02, 0x01, 0x51, 0x09, 0x06}, {0x3F, 0x40, 0x40, 0x40, 0x3F}, {0x3E, 0x41, 0x51, 0x21, 0x5E},
+ {0x20, 0x40, 0x41, 0x3F, 0x01}, {0x7F, 0x09, 0x09, 0x09, 0x01}, /* (U Q J F: the pause menu's) */
};
/* the attract screen, typed out a letter at a time, and where its lines go */
static const char attract[] = "PLAY\0SPACE INVADERS\0*SCORE ADVANCE TABLE*\0=? MYSTERY\0=30 POINTS\0=20 POINTS\0=10 POINTS";
@@ -213,14 +214,39 @@ static const uint16_t *look(int i) { return art[i / 22 * 2 + (st[i] >> 1)]; }
/* ------------------------------------------------------------ the screen */
static const char *const items[2][2] = {{T("Resume"), T("Quit game")}, {T("No"), T("Yes")}};
+/* the pause menu in the arcade's own letters, white on black, the squid pointing at the choice in the
+ film's green (in the arcade's letters when they have every letter of a text, else NumPlay's) */
+static int glyph(int ch) {
+ ch = ch >= 'a' && ch <= 'z' ? ch - 32 : ch;
+ for (int g = 0; glyphs[g]; g++)
+ if (glyphs[g] == ch) return g;
+ return ch == ' ' ? -1 : -2;
+}
+static int atext(int cx, int y, const char *s, int k, color_t c) { /* returns where it begins */
+ int n = 0;
+ for (const char *t = s; *t; t++) n += glyph((uint8_t)*t) > -2 ? 1 : 1000;
+ if (n >= 1000) { /* a letter the arcade didn't have */
+ gfx_text_center(&np_font_body, cx, y + 7 * k, s, c, 256);
+ return cx - gfx_text_width(&np_font_body, s) / 2;
+ }
+ int x0 = cx - (n * 8 - 3) * k / 2;
+ for (int x = x0; *s; s++, x += 8 * k) {
+ int g = glyph((uint8_t)*s);
+ for (int col = 0; g >= 0 && col < 5; col++)
+ for (int r = 0; r < 7; r++)
+ if (font[g][col] >> r & 1) gfx_fill(x + col * k, y + r * k, k, k, c);
+ }
+ return x0;
+}
static void overlay(void) {
- gfx_rrect(70, 60, 180, 120, 8, 0, 256);
- gfx_rrect_outline(70, 60, 180, 120, 8, 2, WHITE, 256);
- gfx_text_center(&np_font_title, 160, 92, ov == OV_PAUSE ? T("Paused") : T("Quit game?"), WHITE, 256);
+ gfx_fill(64, 72, 192, 96, 0);
+ atext(160, 84, ov == OV_PAUSE ? T("Paused") : T("Quit game?"), 2, WHITE);
for (int i = 0; i < 2; i++) {
- int y = 106 + 32 * i;
- if (sel == i) gfx_rrect(100, y, 120, 24, 4, GREEN, 256);
- gfx_text_center(&np_font_body, 160, y + 17, items[ov - 1][i], sel == i ? 0 : WHITE, 256);
+ int y = 120 + 20 * i;
+ int x = atext(160, y, items[ov - 1][i], 1, sel == i ? GREEN : WHITE) - 22;
+ for (int r = 0; sel == i && r < 8; r++)
+ for (int b = 0; b < 16; b++)
+ if (art[4][r] << b & 0x8000) gfx_fill(x + b, y + r - 1, 1, 1, GREEN);
}
}
diff --git a/games/sudoku/src/main.c b/games/sudoku/src/main.c
index 4b124eb2..a0d3a1c8 100644
--- a/games/sudoku/src/main.c
+++ b/games/sudoku/src/main.c
@@ -299,8 +299,12 @@ static const uint8_t buttons[5] = {0, 4, 4, 1, 2}, leads[5][4] = {
static void overlay(void) {
char s[16];
int n = buttons[ov], extra = ov == OV_HELP || ov == OV_WON ? 56 : 0, y = (SCREEN_H - 54 - extra - 32 * n) / 2;
+ /* drawn like a box of the grid: a thick navy edge, the choices in cells split by thin lines, the one
+ picked shaded as the cell picked is */
gfx_fill_alpha(0, 0, SCREEN_W, SCREEN_H, NAVY, 110);
- gfx_rrect(60, y, 200, 54 + extra + 32 * n, 14, WHITE, 256);
+ gfx_fill(58, y - 2, 204, 58 + extra + 32 * n, NAVY);
+ gfx_fill(60, y, 200, 54 + extra + 32 * n, WHITE);
+ gfx_fill(76, y + 48 + extra - 1, 168, 32 * n + 1, LINE);
say(&np_font_title, 160, y + 34, cards[ov][0], NAVY);
y += 48;
if (ov == OV_HELP)
@@ -312,7 +316,8 @@ static void overlay(void) {
y += extra;
for (int i = 0; i < n; i++, y += 32) {
color_t c = menu == i ? WHITE : NAVY;
- gfx_rrect(80, y, 160, 26, 13, menu == i ? BLUE : TILE, 256);
+ gfx_fill(77, y, 166, 31, menu == i ? PICK : WHITE);
+ c = NAVY;
say(&np_font_body, 160, y + 18, ov == OV_MENU && i == 3 && quit_ok ? T("OK again to quit") : cards[ov][i + 1], c);
if (ov == OV_LEVEL && sv.best[i]) gfx_text_right(&np_font_small, 232, y + 17, clock_text(s, sv.best[i]), c, 256);
}
diff --git a/games/twoplayer/src/icon.png b/games/twoplayer/src/icon.png
index 26a4eab4..25706cf3 100644
Binary files a/games/twoplayer/src/icon.png and b/games/twoplayer/src/icon.png differ
diff --git a/games/twoplayer/src/main.c b/games/twoplayer/src/main.c
index 5b1e5ae9..58331eb2 100644
--- a/games/twoplayer/src/main.c
+++ b/games/twoplayer/src/main.c
@@ -650,13 +650,33 @@ static void button(int x, int y, int w, const char *s, bool on) {
box(x, y, w, 26, 13, on ? GOLD : HEX(0x3A4372));
gfx_text_center(&np_font_body, x + w / 2, y + 18, s, on ? INK : WHITE, 256);
}
-/* a card over the game: its title, then its buttons from by down */
+/* a card over the game: its title, then its buttons from by down. Over a game it is drawn in that game's
+ look: Pong's black court and white walls with its square ball, the air hockey rink with a mallet, the tanks' grey maze, the light cycles' blue grid; over the menu, in the menu's */
static void card(int y, int h, const char *title, const char *const *items, int n, int by) {
gfx_fill_alpha(0, 0, SCREEN_W, SCREEN_H, 0, 130);
- box(60, y, 200, h, 14, HEX(0x262D52));
- gfx_rrect_outline(60, y, 200, h, 14, 2, HEX(0x56619A), 256);
- say(&np_font_title, 160, y + 30, title, WHITE);
- for (int i = 0; i < n; i++) button(84, by + 32 * i, 152, items[i], sel == i);
+ if (screen <= S_RULES || (screen == S_ASK && back_to == S_MENU)) {
+ box(60, y, 200, h, 14, HEX(0x262D52));
+ gfx_rrect_outline(60, y, 200, h, 14, 2, HEX(0x56619A), 256);
+ say(&np_font_title, 160, y + 30, title, WHITE);
+ for (int i = 0; i < n; i++) button(84, by + 32 * i, 152, items[i], sel == i);
+ return;
+ }
+ static const uint32_t LOOK[NG][3] = {{0x000000, 0xFFFFFF, 0xFFFFFF}, {0xF4F6FA, 0x9AA3B8, 0x161A33},
+ {0xE6E6EA, 0x3A3D4F, 0x3A3D4F}, {0x0B1230, 0x3E8BFF, 0xFFFFFF}};
+ color_t bg = gfx_rgb(LOOK[game][0]), edge = gfx_rgb(LOOK[game][1]), ink = gfx_rgb(LOOK[game][2]);
+ gfx_fill(57, y - 3, 206, h + 6, edge);
+ gfx_fill(60, y, 200, h, bg);
+ if (game == CYCLES)
+ for (int k = 16; k < 200; k += 16) gfx_fill(60 + k, y, 1, h, HEX(0x1C2A55)), k < h ? gfx_fill(60, y + k, 200, 1, HEX(0x1C2A55)) : (void)0;
+ say(&np_font_title, 160, y + 30, title, ink);
+ for (int i = 0; i < n; i++) {
+ int ty = by + 32 * i + 18, x = 160 - gfx_text_width(&np_font_body, items[i]) / 2 - 16;
+ gfx_text_center(&np_font_body, 160, ty, items[i], sel == i && game ? team[0] : ink, 256);
+ if (sel != i) continue;
+ if (game == PONG) gfx_fill(x, ty - 9, 6, 6, WHITE); /* the ball */
+ else if (game == HOCKEY) gfx_circle(x + 3, ty - 6, 6, team[0], 256), gfx_circle(x + 3, ty - 6, 3, light[0], 256);
+ else gfx_fill(x - 6, ty - 7, 12, 3, team[0]); /* a shot, a trail */
+ }
}
/* the little picture of each game in the menu: x, y, w, h, roundness, colour (red, blue, white) */
diff --git a/games/twoplayer/tools/icon.py b/games/twoplayer/tools/icon.py
new file mode 100644
index 00000000..45c67bfe
--- /dev/null
+++ b/games/twoplayer/tools/icon.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+"""Draws src/icon.png (55 x 56): the 1972 arcade Pong court that opens 2 Players: black, its white walls, the
+dashed net, both paddles, the square ball and the scores in the arcade's three-by-five block digits. Drawn 8
+times bigger, then scaled down; run tools/round_icons.py on it after (NumPlay's rounded corners).
+
+Usage: icon.py [src/icon.png]
+"""
+import os
+import sys
+
+from PIL import Image, ImageDraw
+
+K = 8
+im = Image.new("RGB", (55 * K, 56 * K), (0, 0, 0))
+d = ImageDraw.Draw(im)
+
+
+def box(x0, y0, x1, y1):
+ d.rectangle((x0 * K, y0 * K, x1 * K - 1, y1 * K - 1), fill=(255, 255, 255))
+
+
+DIGITS = {1: ["010", "110", "010", "010", "111"], 3: ["111", "001", "111", "001", "111"]}
+
+
+def digit(n, x, y, s=2):
+ for r, row in enumerate(DIGITS[n]):
+ for c, on in enumerate(row):
+ if on == "1":
+ box(x + c * s, y + r * s, x + c * s + s, y + r * s + s)
+
+
+box(0, 4, 55, 6) # the walls
+box(0, 50, 55, 52)
+for y in range(8, 50, 6): # the net
+ box(27, y, 29, y + 3)
+digit(3, 15, 10)
+digit(1, 34, 10)
+box(6, 26, 8, 36) # the paddles
+box(47, 18, 49, 28)
+box(36, 30, 38, 32) # the ball
+out = sys.argv[1] if len(sys.argv) > 1 else os.path.join(os.path.dirname(__file__), "..", "src", "icon.png")
+im.resize((55, 56), Image.LANCZOS).save(out)
diff --git a/games/uttt/src/main.c b/games/uttt/src/main.c
index 9e7a7bc6..e49b3038 100644
--- a/games/uttt/src/main.c
+++ b/games/uttt/src/main.c
@@ -134,9 +134,10 @@ static void mark(int who, int x, int y, int s, color_t c) {
if (who) gfx_rrect_outline(x - s / 2, y - s / 2, s, s, s / 2, 2 * t, c, 256);
else stroke(x - h, y - h, x + h, y + h, 2 * h, t, c), stroke(x - h, y + h, x + h, y - h, 2 * h, t, c);
}
+/* a choice in the menus, as a move on a board: the one picked is marked with X, in X's colour */
static void button(int y, const char *s, bool on) {
- box(75, y, 170, 26, on ? WHITE : HEX(0x3A4374));
- gfx_text_center(&np_font_body, 160, y + 18, s, on ? PLATE : WHITE, 256);
+ gfx_text_center(&np_font_body, 160, y + 18, s, on ? WHITE : PALE, 256);
+ if (on) mark(0, 160 - gfx_text_width(&np_font_body, s) / 2 - 16, y + 13, 12, HEX(0xFF4D6D));
}
static const char *const OPP[4] = {T("vs a friend"), T("vs easy"), T("vs normal"), T("vs hard")};
@@ -152,7 +153,8 @@ static void overlay(void) {
button(188, T("Play"), true);
return;
}
- box(60, 44, 200, 152, PLATE);
+ box(60, 44, 200, 152, PLATE); /* a small board: its # in the middle, under the choices */
+ for (int i = 1; i < 3; i++) gfx_fill(60 + 200 * i / 3 - 1, 50, 3, 140, SQUARE), gfx_fill(66, 44 + 152 * i / 3 - 1, 188, 3, SQUARE);
gfx_text_center(&np_font_title, 160, 72, T("Paused"), WHITE, 256);
const char *items[3] = {T("Resume"), T("New game"), sure ? T("Quit game?") : T("Quit game")};
for (int i = 0; i < 3; i++) button(84 + 30 * i, items[i], sel == i);