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.

Sokoban: the classic warehouse look

Mason363ed1d9843044d
diff --git a/docs/media/gallery/sokoban.gif b/docs/media/gallery/sokoban.gif
index 9ef84aeb..be882e29 100644
Binary files a/docs/media/gallery/sokoban.gif and b/docs/media/gallery/sokoban.gif differ
diff --git a/docs/media/sokoban.gif b/docs/media/sokoban.gif
index 1920efba..33614a6b 100644
Binary files a/docs/media/sokoban.gif and b/docs/media/sokoban.gif differ
diff --git a/docs/media/thumb_sokoban.png b/docs/media/thumb_sokoban.png
index cd6ff0e5..6f8c81af 100644
Binary files a/docs/media/thumb_sokoban.png and b/docs/media/thumb_sokoban.png differ
diff --git a/docs/play.md b/docs/play.md
index 14fab825..51c36f67 100644
--- a/docs/play.md
+++ b/docs/play.md
@@ -731,7 +731,7 @@ Nine small boards make a big one. The cell you take sends the other player to th
## Sokoban
-<img src="media/sokoban.gif" width="320" align="right" alt="Sokoban: Microban's second and fourth levels solved, the crates turning green on their goals">
+<img src="media/sokoban.gif" width="320" align="right" alt="Sokoban: Microban's second and fourth levels solved, the crates turning dark on their goals">
| Key | What it does |
| --- | --- |
@@ -740,7 +740,7 @@ Nine small boards make a big one. The cell you take sends the other player to th
| **OK** or **EXE** | Choose |
| **Back** | Pause: Resume, Restart, Levels, How to play, Quit game |
-Push every crate onto a goal: the keeper pushes one at a time and can't pull, so a crate in a corner stays there. Microban's 155 levels by David W. Skinner, the first 35 inside NumPlay and all of them in Sokoban.nwa; solved levels turn green on the level list, and the fewest moves for each are kept.
+Push every crate onto a goal: the keeper pushes one at a time and can't pull, so a crate in a corner stays there. Microban's 155 levels by David W. Skinner, the first 35 inside NumPlay and all of them in Sokoban.nwa; solved levels turn dark on the level list, and the fewest moves for each are kept.
<br clear="right">
diff --git a/games/games.json b/games/games.json
index 44206a49..da6b4a76 100644
--- a/games/games.json
+++ b/games/games.json
@@ -438,9 +438,9 @@
"title": "Sokoban",
"tagline": "Push every box home",
"credit": "Levels: Microban by David W. Skinner",
- "top": "0xC9843F",
- "bottom": "0x2B2730",
- "accent": "0xF2B53C",
+ "top": "0xA19555",
+ "bottom": "0x444024",
+ "accent": "0xFFB650",
"colors": 11,
"records": [
"sokoban.sav"
diff --git a/games/sokoban/README.md b/games/sokoban/README.md
index 661a4580..49986728 100644
--- a/games/sokoban/README.md
+++ b/games/sokoban/README.md
@@ -2,17 +2,17 @@
Push every box onto a goal. Hiroyuki Imabayashi's warehouse puzzle on the NumWorks calculator, with David W. Skinner's Microban: 155 levels, from the very first push to The Dungeon.
-<img src="docs/shot.png" width="320" alt="Sokoban's first level: the keeper in his red cap between a crate on its goal and a crate still to push">
+<img src="docs/shot.png" width="320" alt="Sokoban's first level: the warehouse keeper between brick walls, a crate on its goal and a crate still to push">
- **Microban's 155 levels**, small ones that each show an idea, the easy ones first. **Sokoban.nwa** has all 155; **inside NumPlay** there's room for the first 35. Both keep the same progress, so a level solved in one is solved in the other.
- **The rules of the original:** the keeper pushes the boxes one at a time and can never pull them, so a box pushed into a corner stays there.
- **Undo** takes back your steps one at a time, hundreds of them; **Restart** puts the level back as it began.
- **Moves and pushes** are counted, and the fewest moves you solved each level in are kept.
-- **The levels**, ten to a row: the ones you solved are green. A level opens while fewer than three before it are still unsolved, so one that blocks you never stops you for good.
+- **The levels**, ten to a row, each a crate: the ones you solved turn dark like a crate on its goal, the ones still shut are bricks. A level opens while fewer than three before it are still unsolved, so one that blocks you never stops you for good.
- **The levels as Microban has them**, wall for wall, down to the decorations of The Dungeon; big ones shrink to fit the screen.
-- **The classic look**: brick walls, wooden crates that turn green on their goals, and the warehouse keeper in his red cap, who looks the way he walks. The keeper steps a cell at a time, as in the original.
+- **The classic look**: olive brick walls, a sandy floor with pink goal dots, wooden crates with an X that turn dark on their goals, and the warehouse keeper with his black hair, white shirt and blue trousers, the way Sokoban is usually drawn. The pause menu is a sign of planks. The keeper steps a cell at a time, as in the original.
-<img src="docs/levels.png" width="320" alt="The level list: the first seventeen levels solved in green, the next three open">
+<img src="docs/levels.png" width="320" alt="The level list: the first seventeen levels solved, the next three open, the rest still bricks">
## Controls
diff --git a/games/sokoban/docs/levels.png b/games/sokoban/docs/levels.png
index 42d5593c..9bbec67a 100644
Binary files a/games/sokoban/docs/levels.png and b/games/sokoban/docs/levels.png differ
diff --git a/games/sokoban/docs/shot.png b/games/sokoban/docs/shot.png
index b2772c66..d7401ecd 100644
Binary files a/games/sokoban/docs/shot.png and b/games/sokoban/docs/shot.png differ
diff --git a/games/sokoban/lang/fr.txt b/games/sokoban/lang/fr.txt
index 0bf5169d..860230b8 100644
--- a/games/sokoban/lang/fr.txt
+++ b/games/sokoban/lang/fr.txt
@@ -16,3 +16,4 @@ Level Niveau
Moves Pas
Pushes Poussées
Your best: Ton record :
+OK play Back quit OK : jouer Retour : quitter
diff --git a/games/sokoban/lang/zh.txt b/games/sokoban/lang/zh.txt
index d65d78d7..97222323 100644
--- a/games/sokoban/lang/zh.txt
+++ b/games/sokoban/lang/zh.txt
@@ -16,3 +16,4 @@ Level 关卡
Moves 步数
Pushes 推动
Your best: 最佳:
+OK play Back quit OK 开始 Back 退出
diff --git a/games/sokoban/src/icon.png b/games/sokoban/src/icon.png
index 74fe5552..2d8ce4f7 100644
Binary files a/games/sokoban/src/icon.png and b/games/sokoban/src/icon.png differ
diff --git a/games/sokoban/src/main.c b/games/sokoban/src/main.c
index b7685328..9c769f02 100644
--- a/games/sokoban/src/main.c
+++ b/games/sokoban/src/main.c
@@ -24,8 +24,10 @@
#include "../../common/epsilon_files.h"
#define np_file_read ef_read
#define np_file_write ef_write
+#ifndef HOST /* (a computer build of the tests has no app header) */
const char eadk_app_name[] __attribute__((section(".rodata.eadk_app_name"))) = "Sokoban";
const uint32_t eadk_api_level __attribute__((section(".rodata.eadk_api_level"))) = 0;
+#endif
void np_push(int x, int y, int w, int h, const color_t *px) {
eadk_display_push_rect((eadk_rect_t){(uint16_t)x, (uint16_t)y, (uint16_t)w, (uint16_t)h}, px);
}
@@ -47,12 +49,20 @@ static uint32_t keys(void) {
#define F_WALL 8
#define F_NONE 16 /* (while a level opens) no wall here, though there is floor next to it */
+/* the warehouse's colours, as Sokoban is usually drawn: sand, olive bricks, wooden crates */
#define WHITE 0xFFFF
-#define BG HEX(0x2B2730) /* around the warehouse */
-#define BAR HEX(0x1C1A20)
-#define CREAM HEX(0xF2E6CF)
-#define GOLD HEX(0xF2B53C)
-#define GREEN HEX(0x5DAE45)
+#define BG HEX(0xDED6AE) /* the sand floor, and around the warehouse */
+#define SPECK HEX(0xC6BE95) /* the sand's marks */
+#define BRICK HEX(0xA19555)
+#define MORTAR HEX(0x444024)
+#define DOT HEX(0xD69585) /* a goal */
+#define WOOD HEX(0xFFB650)
+#define WOOD2 HEX(0xDA7D00)
+#define WOOD3 HEX(0xBA650C)
+#define WOOD4 HEX(0x8D2C00)
+#define INK 0
+#define BAR MORTAR
+#define CREAM HEX(0xFFDAAA)
/* sokoban.sav: the level played last, and the fewest moves each level was solved in (0: not yet), for
all of Microban whatever this build holds, so NumPlay and Sokoban.nwa share it */
@@ -66,7 +76,7 @@ static struct {
the first and last cells) */
static uint8_t g[MAXW * (MAXH + 2) + 2];
#define G (g + MAXW + 1)
-static const int8_t off[4] = {-MAXW, 1, MAXW, -1}, ddx[4] = {0, 1, 0, -1}; /* up, right, down, left */
+static const int8_t off[4] = {-MAXW, 1, MAXW, -1}; /* up, right, down, left */
static uint8_t hist[HIST]; /* the steps taken: the way, and 4 for a push */
static color_t strip[SCREEN_W * STRIP_H];
static int level, rows, size, ox, oy, keeper, face, left, moves, pushes, nh;
@@ -158,13 +168,18 @@ static void undo(void) {
}
/* ------------------------------------------------------------ drawing */
-static void box(int i) {
- int s = size, x = ox + i % MAXW * s, y = oy + i / MAXW * s;
- color_t dark = G[i] & F_GOAL ? HEX(0x3F7A2C) : HEX(0x8A5422);
- gfx_rrect(x + 1, y + 1, s - 2, s - 2, s / 5, dark, 256);
- gfx_rrect(x + 3, y + 3, s - 6, s - 6, s / 5 - 1, G[i] & F_GOAL ? GREEN : HEX(0xD6943E), 256);
- gfx_fill(x + 3, y + s / 2 - 1, s - 6, 2, dark);
+/* a wooden crate: a black edge, a frame and an X of planks; darker on a goal */
+static void crate(int x, int y, int s, bool goal) {
+ int t = s / 12 + 1, m = s - 2 - 2 * t, ix = x + 1 + t, iy = y + 1 + t;
+ gfx_fill(x, y, s, s, INK);
+ gfx_fill(x + 1, y + 1, s - 2, s - 2, goal ? WOOD3 : WOOD2);
+ gfx_fill(ix, iy, m, m, goal ? WOOD4 : WOOD);
+ for (int k = 0; k + t <= m; k++) {
+ gfx_fill(ix + k, iy + k, t, t, goal ? WOOD3 : WOOD2);
+ gfx_fill(ix + m - t - k, iy + k, t, t, goal ? WOOD3 : WOOD2);
+ }
}
+static void box(int i) { crate(ox + i % MAXW * size, oy + i / MAXW * size, size, G[i] & F_GOAL); }
/* the panels in the middle (OV_PAUSE to OV_DONE): a title, a few lines, then the choices, the one
picked in gold */
static const char *const panels[4][6] = {
@@ -174,15 +189,18 @@ static const char *const panels[4][6] = {
{T("Solved!"), T("Next level")},
};
static const uint8_t choices[4] = {5, 2, 1, 1}, lines[4] = {0, 0, 4, 1};
-static void overlay(void) {
+static void overlay(void) { /* a sign of planks, like the crates */
int n = choices[ov - 1], h = 54 + 16 * lines[ov - 1] + 28 * n, y = (SCREEN_H - h) / 2;
- gfx_fill_alpha(0, 0, SCREEN_W, SCREEN_H, 0, 110);
- gfx_rrect(40, y, 240, h, 12, BAR, 256);
- gfx_text_center(&np_font_title, 160, y + 32, panels[ov - 1][0], GOLD, 256);
- y = gfx_paragraph(&np_font_body, 160, y + 54, 224, 16, ov == OV_HELP ? T("Push every box onto a goal: they can't be pulled.\nArrows: walk Backspace: undo\nBack: pause") : ov == OV_DONE ? msg : "", CREAM, 256) - 12;
+ gfx_fill_alpha(0, 0, SCREEN_W, SCREEN_H, MORTAR, 110);
+ gfx_fill(38, y - 2, 244, h + 4, INK);
+ gfx_fill(40, y, 240, h, WOOD3);
+ gfx_fill(44, y + 4, 232, h - 8, WOOD);
+ for (int k = y + 22; k < y + h - 8; k += 22) gfx_fill(44, k, 232, 1, WOOD2);
+ gfx_text_center(&np_font_title, 160, y + 32, panels[ov - 1][0], WOOD4, 256);
+ y = gfx_paragraph(&np_font_body, 160, y + 54, 224, 16, ov == OV_HELP ? T("Push every box onto a goal: they can't be pulled.\nArrows: walk Backspace: undo\nBack: pause") : ov == OV_DONE ? msg : "", MORTAR, 256) - 12;
for (int i = 0; i < n; i++, y += 28) {
- if (sel == i) gfx_rrect(96, y, 128, 24, 12, GOLD, 256);
- gfx_text_center(&np_font_body, 160, y + 17, panels[ov - 1][i + 1], sel == i ? BAR : CREAM, 256);
+ if (sel == i) gfx_rrect(92, y, 136, 24, 4, WOOD4, 256);
+ gfx_text_center(&np_font_body, 160, y + 17, panels[ov - 1][i + 1], sel == i ? CREAM : MORTAR, 256);
}
}
@@ -192,48 +210,60 @@ static void play_scene(void *ctx) {
for (int i = 0; i < rows * MAXW; i++) {
int x = ox + i % MAXW * s, y = oy + i / MAXW * s, f = G[i];
if (y >= gfx_y1 || y + s <= gfx_y0) continue;
- if (f & F_WALL) { /* bricks, two rows a cell, the joints staggered */
- gfx_fill(x, y, s, s, HEX(0xA4613C));
- gfx_fill(x, y + s / 2 - 1, s, 1, HEX(0x5B3A26));
- gfx_fill(x, y + s - 1, s, 1, HEX(0x5B3A26));
- gfx_fill(x + s / 2, y, 1, s / 2, HEX(0x5B3A26));
- gfx_fill(x, y + s / 2, 1, s - s / 2, HEX(0x5B3A26));
+ if (f & F_WALL) { /* olive bricks, four rows a cell (two when small), the joints staggered */
+ int n = s >= 16 ? 4 : 2;
+ gfx_fill(x, y, s, s, BRICK);
+ for (int r = 0; r < n; r++) {
+ int ry = y + r * s / n, rh = (r + 1) * s / n - r * s / n;
+ gfx_fill(x, ry + rh - 1, s, 1, MORTAR);
+ gfx_fill(x + (r & 1 ? s / 4 : 0), ry, 1, rh, MORTAR);
+ gfx_fill(x + (r & 1 ? s * 3 / 4 : s / 2), ry, 1, rh, MORTAR);
+ }
} else if (f) {
- gfx_fill(x, y, s, s, (i ^ i / MAXW) & 1 ? HEX(0xE4D7BC) : HEX(0xDCCDAF));
- if (f & F_GOAL) gfx_circle(x + s / 2, y + s / 2, s / 5 + 1, HEX(0xD2452F), 256);
+ gfx_fill(x + (i * 5 % 7) * s / 9 + 1, y + s / 4, s / 5, 1, SPECK); /* the sand's marks */
+ gfx_fill(x + (i * 3 % 5) * s / 8 + 2, y + s * 3 / 4, s / 6, 1, SPECK);
+ if (f & F_GOAL) gfx_circle(x + s / 2, y + s / 2, s / 6 + 1, DOT, 256);
if (f & F_BOX) box(i);
}
}
- /* the keeper: a warehouse man in blue overalls and a red cap, looking the way he goes */
- int cx = ox + keeper % MAXW * s + s / 2, cy = oy + keeper / MAXW * s + s / 2;
- gfx_rrect(cx - s * 5 / 16, cy - s / 16, s * 5 / 8, s * 7 / 16, s / 6, HEX(0x2F5FC4), 256);
- gfx_circle(cx, cy - s / 6, s / 4, HEX(0xF2C29B), 256);
- gfx_rrect(cx - s / 4, cy - s * 7 / 16, s / 2, s / 6 + 1, s / 12, HEX(0xC83A2C), 256);
- for (int e = -1; e <= 1 && face; e += 2) /* (from behind, no eyes) */
- gfx_fill(cx + e * s / 10 + ddx[face] * s / 10 - s / 32, cy - s / 7, s / 16 + 1, s / 10 + 1, BAR);
- gfx_fill(0, 0, SCREEN_W, HDR, BAR);
+ /* the warehouse keeper, facing us: black hair, a white shirt, blue trousers */
+ int x = ox + keeper % MAXW * s, y = oy + keeper / MAXW * s, c = x + s / 2, u = s / 16 + (s < 16);
+ gfx_fill(c - s * 5 / 16, y + s * 8 / 16, s * 5 / 8, s * 4 / 16, CREAM); /* the arms */
+ gfx_rrect(c - s / 4, y + s * 7 / 16, s / 2, s * 5 / 16, u, HEX(0xDADADA), 256); /* the shirt */
+ gfx_fill(c + s / 8, y + s * 7 / 16, s / 8, s * 5 / 16, HEX(0xC6C6C6));
+ gfx_fill(c - s / 4, y + s * 11 / 16, s / 2, s * 3 / 16, HEX(0x2895FF)); /* the trousers */
+ gfx_fill(c, y + s * 12 / 16, u, s * 2 / 16, HEX(0x0061BA));
+ gfx_fill(c - s / 4, y + s * 14 / 16, s / 2, u + 1, HEX(0x996D40)); /* the shoes */
+ gfx_rrect(c - s * 3 / 16, y + s * 2 / 16, s * 3 / 8, s * 6 / 16, u, CREAM, 256); /* the face */
+ gfx_rrect(c - s * 7 / 32, y + s / 16, s * 7 / 16, s * 3 / 16, u, INK, 256); /* the hair */
+ gfx_fill(c - s / 8, y + s * 5 / 16, u, u + 1, INK); /* the eyes */
+ gfx_fill(c + s / 8 - u + 1, y + s * 5 / 16, u, u + 1, INK);
+ gfx_fill(0, 0, SCREEN_W, HDR, MORTAR);
put(line, T("Level "), (uint32_t)level + 1);
- gfx_text(&np_font_body, 8, 16, line, GOLD, 256);
+ gfx_text(&np_font_body, 8, 16, line, WOOD, 256);
put(cat(put(line, T("Moves "), (uint32_t)moves), " "), T("Pushes "), (uint32_t)pushes);
gfx_text_right(&np_font_body, 312, 16, line, CREAM, 256);
if (ov) overlay();
}
/* the levels, ten a row, six rows on the screen at a time */
-static void hub_scene(void *ctx) {
+static void hub_scene(void *ctx) { /* a crate a level: dark once solved; bricks while it's shut */
char s[8];
gfx_fill(0, 0, SCREEN_W, SCREEN_H, BG);
- gfx_fill(0, 0, SCREEN_W, 36, BAR);
- gfx_text(&np_font_title, 12, 27, "SOKOBAN", GOLD, 256);
+ gfx_fill(0, 0, SCREEN_W, 36, MORTAR);
+ gfx_text(&np_font_title, 12, 27, "SOKOBAN", WOOD, 256);
+ gfx_text_right(&np_font_small, 308, 24, T("OK play Back quit"), CREAM, 256);
for (int i = 0; i < LEVELS; i++) {
- int x = 12 + 30 * (i % 10), y = 46 + 27 * (i / 10 - top);
+ int x = 13 + 30 * (i % 10), y = 44 + 27 * (i / 10 - top);
if (y < 40 || y > 190) continue;
- gfx_rrect(x, y, 26, 22, 6, sv.best[i] ? GREEN : unlocked(i) ? CREAM : HEX(0x57505E), 256);
- if (i == pick) gfx_rrect_outline(x - 3, y - 3, 32, 28, 8, 2, GOLD, 256);
+ if (i == pick) gfx_fill(x - 3, y - 3, 30, 30, INK);
+ if (unlocked(i)) crate(x, y, 24, sv.best[i]);
+ else gfx_fill(x, y, 24, 24, BRICK), gfx_fill(x, y + 11, 24, 1, MORTAR), gfx_fill(x + 12, y, 1, 11, MORTAR);
put(s, "", (uint32_t)i + 1);
- gfx_text_center(&np_font_small, x + 13, y + 15, s, sv.best[i] ? WHITE : BG, 256);
+ gfx_rrect(x + 4, y + 6, 16, 12, 3, unlocked(i) ? CREAM : BRICK, 256);
+ gfx_text_center(&np_font_small, x + 12, y + 16, s, unlocked(i) ? WOOD4 : MORTAR, 256);
}
- gfx_fill(0, 214, SCREEN_W, 26, BAR);
+ gfx_fill(0, 214, SCREEN_W, 26, MORTAR);
put(line, T("Your best: "), sv.best[pick]);
if (sv.best[pick]) gfx_text_center(&np_font_body, 160, 232, line, CREAM, 256);
if (ov) overlay();
diff --git a/games/sokoban/tools/icon.py b/games/sokoban/tools/icon.py
index 30f52fb2..83808e16 100644
--- a/games/sokoban/tools/icon.py
+++ b/games/sokoban/tools/icon.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
-"""Draws src/icon.png (55 x 56): the keeper pushing a crate onto a goal, between brick walls, in the
-game's colours. Drawn 8 times bigger, then scaled down.
+"""Draws src/icon.png (55 x 56): the warehouse keeper next to a wooden crate, between olive brick walls on
+the sand floor, in the game's colours (the way Sokoban is usually drawn). 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]
"""
@@ -11,45 +12,53 @@ from PIL import Image, ImageDraw
K = 8
W, H = 55 * K, 56 * K
-im = Image.new("RGBA", (W, H), (0, 0, 0, 0))
+im = Image.new("RGB", (W, H), (0xDE, 0xD6, 0xAE))
d = ImageDraw.Draw(im)
-cell = 13 * K
-x0, y0 = (W - 4 * cell) // 2, (H - 4 * cell) // 2
def rgb(v):
- return (v >> 16, v >> 8 & 255, v & 255, 255)
-
-
-# the floor, a checkerboard, inside a rounded tile of walls
-d.rounded_rectangle((0, 0, W - 1, H - 1), radius=12 * K, fill=rgb(0x8C5A3A))
-for r in range(4):
- for c in range(4):
- x, y = x0 + c * cell, y0 + r * cell
- if r in (0, 3) or c in (0, 3): # bricks around
- d.rectangle((x, y, x + cell - 1, y + cell - 1), fill=rgb(0x5B3A26))
- d.rectangle((x, y, x + cell - K - 1, y + cell - K - 1), fill=rgb(0xB57D55))
- d.rectangle((x + K, y + K, x + cell - K - 1, y + cell - K - 1), fill=rgb(0x8C5A3A))
- else:
- d.rectangle((x, y, x + cell - 1, y + cell - 1), fill=rgb(0xE4D7BC if (r ^ c) & 1 else 0xDCCDAF))
-# a crate pushed onto its goal, the keeper behind it looking at it; below, a crate and a goal to go
-def crate(x, y, dark, face):
- d.rounded_rectangle((x + K, y + K, x + cell - K, y + cell - K), radius=3 * K, fill=rgb(dark))
- d.rounded_rectangle((x + 3 * K, y + 3 * K, x + cell - 3 * K, y + cell - 3 * K), radius=2 * K, fill=rgb(face))
- d.rectangle((x + 3 * K, y + cell // 2 - K, x + cell - 3 * K, y + cell // 2 + K), fill=rgb(dark))
-
-
-crate(x0 + 2 * cell, y0 + cell, 0x3F7A2C, 0x5DAE45)
-crate(x0 + cell, y0 + 2 * cell, 0x8A5422, 0xD6943E)
-gx, gy = x0 + 2 * cell + cell // 2, y0 + 2 * cell + cell // 2
-d.ellipse((gx - 3 * K, gy - 3 * K, gx + 3 * K, gy + 3 * K), fill=rgb(0xD2452F))
-x, y = x0 + cell, y0 + cell
-cx, cy, rr = x + cell // 2, y + cell // 2, cell * 3 // 8
-d.ellipse((cx - rr, cy - rr + K, cx + rr, cy + rr + K), fill=rgb(0x1D3F8A))
-d.ellipse((cx - rr, cy - rr, cx + rr, cy + rr), fill=rgb(0x3C7BE8))
-for e in (-1, 1):
- ex, ey = cx + e * cell // 7 + 2 * K, cy - cell // 12
- d.ellipse((ex - 2 * K, ey - 2 * K, ex + 2 * K, ey + 2 * K), fill=(255, 255, 255, 255))
- d.ellipse((ex, ey - K, ex + 2 * K, ey + K), fill=rgb(0x1C1A20))
+ return (v >> 16, v >> 8 & 255, v & 255)
+
+
+def box(x0, y0, x1, y1, c):
+ d.rectangle((x0 * K, y0 * K, x1 * K - 1, y1 * K - 1), fill=rgb(c))
+
+
+def bricks(y0, y1):
+ """Olive bricks, rows of 5 pixels with dark joints, staggered."""
+ box(0, y0, 55, y1, 0xA19555)
+ for r, y in enumerate(range(y0, y1, 5)):
+ box(0, y + 4, 55, y + 5, 0x444024)
+ for x in range(-6 + 6 * (r & 1), 55, 12):
+ box(x, y, x + 1, y + 4, 0x444024)
+
+
+bricks(0, 10)
+bricks(46, 56)
+# the sand's marks
+for x, y in ((6, 14), (40, 15), (9, 42), (50, 41), (27, 43)):
+ box(x, y, x + 3, y + 1, 0xC6BE95)
+# the crate: a black edge, a frame and an X of planks
+x0, y0, s = 22, 13, 30
+box(x0, y0, x0 + s, y0 + s, 0x000000)
+box(x0 + 1, y0 + 1, x0 + s - 1, y0 + s - 1, 0xDA7D00)
+box(x0 + 4, y0 + 4, x0 + s - 4, y0 + s - 4, 0xFFB650)
+m = s - 8
+for k in range(m - 2):
+ box(x0 + 4 + k, y0 + 4 + k, x0 + 7 + k, y0 + 7 + k, 0xDA7D00)
+ box(x0 + s - 7 - k, y0 + 4 + k, x0 + s - 4 - k, y0 + 7 + k, 0xDA7D00)
+# the keeper, facing us, his hands on the crate
+c = 12
+box(c - 6, 26, c + 11, 31, 0xFFDAAA) # the arms, out to the crate
+box(c - 5, 24, c + 5, 34, 0xDADADA) # the shirt
+box(c + 2, 24, c + 5, 34, 0xC6C6C6)
+box(c - 5, 34, c + 5, 41, 0x2895FF) # the trousers
+box(c, 36, c + 1, 41, 0x0061BA)
+box(c - 6, 41, c - 1, 43, 0x996D40) # the shoes
+box(c + 1, 41, c + 6, 43, 0x996D40)
+box(c - 4, 13, c + 4, 24, 0xFFDAAA) # the face
+box(c - 5, 11, c + 5, 16, 0x000000) # the hair
+box(c - 3, 18, c - 1, 20, 0x000000) # the eyes
+box(c + 1, 18, c + 3, 20, 0x000000)
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)