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.

README: a new NumBlocks clip, smoother (15 frames a second): a walk across a meadow, the inventory, TNT blowing a crater, water poured into it and lava flowing towards it (games/numblocks/tools/readme_gif.py records it, play --showcase)

Mason Chenf5a823ff4bea
diff --git a/README.md b/README.md
index ca1e7cf4..b4cfe0a2 100644
--- a/README.md
+++ b/README.md
@@ -45,7 +45,7 @@ Want a game that isn't here? I'm open to requests: email me at [masonchen204@gma
## New: NumBlocks
<p align="center">
- <img src="docs/media/numblocks.gif" width="640" alt="NumBlocks: chopping a birch tree, then building a pillar of planks and looking out over the forest">
+ <img src="docs/media/numblocks.gif" width="640" alt="NumBlocks: walking across a meadow, the inventory, TNT blowing a crater, water poured into it and lava flowing towards it">
</p>
Mine, craft and survive in a world like Minecraft 1.8, right on your calculator.
@@ -53,6 +53,7 @@ Mine, craft and survive in a world like Minecraft 1.8, right on your calculator.
- **Endless worlds:** the same biomes, caves and trees as Minecraft 1.8.8, for any seed.
- **Survival:** chop trees, craft tools, build a shelter, and fight zombies, skeletons, creepers and spiders at night.
- **Creative:** fly around and build with every block.
+- **TNT, water and lava:** blow craters, and watch water and lava flow (and turn to stone where they meet).
- **Your worlds stay:** keep several, and they come back even after you install again.
<p align="center">
@@ -324,7 +325,7 @@ Upsilon support is new. If it doesn't work on your calculator, please [email me]
<td><img src="docs/media/crossyroad.gif" alt="Crossy Road gameplay"></td>
</tr>
<tr>
- <td><img src="docs/media/numblocks.gif" alt="NumBlocks: chopping a birch tree, then building a pillar of planks"></td>
+ <td><img src="docs/media/numblocks.gif" alt="NumBlocks: the inventory, TNT, water and lava"></td>
<td><img src="docs/media/numblocks_night.gif" alt="NumBlocks: sunset, then a zombie walks up and is beaten with an iron sword"></td>
</tr>
<tr>
diff --git a/docs/media/numblocks.gif b/docs/media/numblocks.gif
index 3851c38c..d1ba9574 100644
Binary files a/docs/media/numblocks.gif and b/docs/media/numblocks.gif differ
diff --git a/docs/play.md b/docs/play.md
index f3958c94..f0bb6ef7 100644
--- a/docs/play.md
+++ b/docs/play.md
@@ -51,7 +51,7 @@ Keep moving, or the eagle gets you. Coins add up across every run and stay saved
## NumBlocks
-<img src="media/numblocks.gif" width="320" align="right" alt="NumBlocks: chopping a birch tree, then building a pillar of planks">
+<img src="media/numblocks.gif" width="320" align="right" alt="NumBlocks: the inventory, TNT, water and lava">
| Key | What it does |
| --- | --- |
diff --git a/games/numblocks/tests/play.c b/games/numblocks/tests/play.c
index 300eaed6..c5b6e741 100644
--- a/games/numblocks/tests/play.c
+++ b/games/numblocks/tests/play.c
@@ -1,6 +1,7 @@
/* Plays NumBlocks on a computer with scripted keys and saves screenshots.
*
* play [--frames N] [--ms-per-frame M] [--keys "10-40:fwd,50:use,..."] [--shots 30,60] [--out DIR]
+ * [--showcase] (the hotbar of the README's GIF: TNT, flint and steel, water and lava, blocks)
*
* Keys: left right up down fwd back sleft sright jump use attack inv sneak sprint pause 1..9. */
#include <stdio.h>
@@ -33,7 +34,7 @@ static uint32_t key_bit(const char *s) {
int main(int argc, char **argv) {
const char *out = "build/play", *shots = "";
- int give = 0, title_screen = 0, mobs = 0, start_time = -1, torches = 0, water = 0, creative = 0, build = 0, rain = 0;
+ int give = 0, showcase = 0, title_screen = 0, mobs = 0, start_time = -1, torches = 0, water = 0, creative = 0, build = 0, rain = 0;
float hurt = 0;
int frames = 60, mspf = 50;
for (int i = 1; i < argc; i++) {
@@ -42,6 +43,7 @@ int main(int argc, char **argv) {
else if (!strcmp(argv[i], "--out") && i + 1 < argc) out = argv[++i];
else if (!strcmp(argv[i], "--shots") && i + 1 < argc) shots = argv[++i];
else if (!strcmp(argv[i], "--give")) give = 1;
+ else if (!strcmp(argv[i], "--showcase")) showcase = 1;
else if (!strcmp(argv[i], "--title")) title_screen = 1;
else if (!strcmp(argv[i], "--mobs")) mobs = 1;
else if (!strcmp(argv[i], "--torches")) torches = 1;
@@ -81,6 +83,17 @@ int main(int argc, char **argv) {
for (unsigned i = 0; i < sizeof kit / sizeof kit[0]; i++) inv_add(pl.inv, 36, kit[i][0], kit[i][1], 0);
pl.inv[0].aux = 100; /* a worn pickaxe */
}
+ if (showcase) {
+ /* the README's GIF: the hotbar first, then a full inventory to look at */
+ static const int kit[][2] = {{B_TNT, 16}, {I_FLINT_AND_STEEL, 1}, {I_WATER_BUCKET, 1}, {I_LAVA_BUCKET, 1},
+ {B_COBBLESTONE, 64}, {B_PLANKS_OAK, 48}, {B_GLASS, 32}, {I_DIAMOND_PICKAXE, 1},
+ {B_TORCH, 32}, {I_DIAMOND_SWORD, 1}, {I_BOW, 1}, {I_ARROW, 48}, {I_DIAMOND, 12},
+ {I_GOLD_INGOT, 21}, {I_IRON_INGOT, 30}, {I_COOKED_BEEF, 9}, {I_BREAD, 7},
+ {I_APPLE, 4}, {B_OBSIDIAN, 10}, {B_DIAMOND_BLOCK, 2}, {B_LOG_OAK, 24},
+ {B_CRAFTING_TABLE, 1}, {B_FURNACE, 2}, {B_CHEST, 3}, {I_IRON_HELMET, 1},
+ {I_IRON_CHESTPLATE, 1}, {B_SAND, 40}};
+ for (unsigned i = 0; i < sizeof kit / sizeof kit[0]; i++) inv_add(pl.inv, 36, kit[i][0], kit[i][1], 0);
+ }
if (start_time >= 0) {
extern uint32_t game_time;
game_time = (uint32_t)start_time;
diff --git a/games/numblocks/tools/readme_gif.py b/games/numblocks/tools/readme_gif.py
new file mode 100644
index 00000000..71b38c48
--- /dev/null
+++ b/games/numblocks/tools/readme_gif.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python3
+"""Records docs/media/numblocks.gif, the README's NumBlocks clip, with the host player (make host):
+a walk across a meadow, the inventory, TNT lit and a crater, water poured in it, lava flowing to it.
+
+Usage (from games/numblocks): python3 tools/readme_gif.py [out.gif]
+Needs ffmpeg and gifsicle."""
+import os
+import shutil
+import subprocess
+import sys
+import tempfile
+
+HERE = os.path.dirname(os.path.abspath(__file__))
+PLAY = os.path.join(HERE, "..", "build", "play")
+OUT = sys.argv[1] if len(sys.argv) > 1 else os.path.join(HERE, "..", "..", "..", "docs", "media", "numblocks.gif")
+FRAMES = 440 # 50 ms each in the game, shown at 15 a second
+K = []
+
+
+def hold(a, b, k):
+ K.append(f"{a}-{b}:{k}")
+
+
+def tap(a, k):
+ K.append(f"{a}-{a + 1}:{k}")
+
+
+# A: walk across the meadow, turning a little, one hop
+hold(4, 40, "fwd"); hold(14, 24, "right"); tap(22, "jump")
+# B: the inventory
+tap(48, "inv"); hold(58, 59, "right"); hold(66, 67, "down"); hold(74, 75, "right"); tap(90, "inv")
+# C: TNT a few blocks ahead, lit, then back off and watch it go
+tap(98, "1"); hold(100, 106, "down"); tap(110, "use"); tap(116, "2"); tap(120, "use")
+hold(124, 168, "back"); hold(126, 129, "up")
+# D: walk up to the crater and look in
+hold(214, 228, "fwd"); hold(230, 238, "down")
+# E: fill it with water
+tap(242, "3"); tap(246, "use")
+# F: lava on the grass a little back from the rim: it flows in and hardens where it meets the water
+hold(282, 300, "right"); hold(302, 307, "up"); tap(310, "4"); tap(314, "use")
+hold(322, 344, "sright"); hold(346, 355, "left"); hold(348, 351, "up")
+
+with tempfile.TemporaryDirectory() as d:
+ subprocess.run([PLAY, "--frames", str(FRAMES), "--seed", "99", "--showcase", "--keys", ",".join(K),
+ "--shots", ",".join(str(f) for f in range(FRAMES)), "--out", d], check=True, capture_output=True)
+ n = 0
+ for k in range(FRAMES * 15 // 20):
+ shutil.copy(os.path.join(d, f"shot_{round(k * 20 / 15)}.ppm"), os.path.join(d, f"s_{n}.ppm"))
+ n += 1
+ raw = os.path.join(d, "raw.gif")
+ subprocess.run(["ffmpeg", "-loglevel", "error", "-y", "-framerate", "15", "-i", os.path.join(d, "s_%d.ppm"), "-vf",
+ "scale=640:480:flags=neighbor,split[a][b];[a]palettegen=max_colors=192:stats_mode=diff[p];"
+ "[b][p]paletteuse=dither=none:diff_mode=rectangle", raw], check=True)
+ subprocess.run(["gifsicle", "-O3", "--lossy=40", raw, "-o", OUT], check=True)
+print(f"{OUT}: {os.path.getsize(OUT) // 1024} KB")