fix(games): correct Snake self-collision on spawn, enlarge Tetris, brighten labels

Snake: the snake was initialized with its head at the left end while
moving right, so the first gravity step walked the head into its own
body and the game started at Game Over. Initialize the head at the
right end (cx) so the initial direction is valid.

Tetris: enlarge the playfield cell (10 -> 12px) so pieces are not too
small, and slow gravity (800ms base, gentler per-level ramp, 250ms
floor) so pieces do not fall too fast.

Both: brighten the secondary/dim text colour (0x0a3a0a -> 0x2f9f2f)
so score/label/menu text is actually legible on the black background.

Also wire the Games section into the real main menu: the system menu
is hardcoded in the dwm-plugin dmenu (src/sxmo-dmenu/dmenu.c), not in
sxmo_appmenu.sh, so add a 'games' builtin menu that loads
sxmo_hook_games.sh and a Games entry after Apps in the sys menu, plus
scripts/build-dmenu.sh to cross-compile dmenu.so.
This commit is contained in:
Luxferre
2026-10-23 14:57:59 +03:00
parent 5f467b02fa
commit 3eb54e4306
10 changed files with 97 additions and 7 deletions
+4 -4
View File
@@ -27,7 +27,7 @@ static const int WIN_W = 240;
static const int WIN_H = 296;
static const int PCOLS = 10;
static const int PROWS = 20;
static const int CELL = 10;
static const int CELL = 12;
// ---- 5x7 bitmap font ----
struct Glyph { char ch; unsigned char r[7]; };
@@ -101,7 +101,7 @@ static int board[PCOLS][PROWS]; // 0 empty, else type+1
static int curType = 0, curRot = 0, curX = 3, curY = 0;
static int nextType = 0;
static int score = 0, best = 0, lines = 0, level = 1;
static int speed = 600; // ms per gravity step
static int speed = 800; // ms per gravity step
static unsigned long nextTick = 0;
static bool running = true;
@@ -176,7 +176,7 @@ static void lock_piece() {
score += pts[cleared] * level;
if (score > best) best = score;
int nl = 1 + lines / 10;
if (nl != level) { level = nl; speed = 600 - (level - 1) * 50; if (speed < 120) speed = 120; }
if (nl != level) { level = nl; speed = 800 - (level - 1) * 40; if (speed < 250) speed = 250; }
}
spawn();
}
@@ -341,7 +341,7 @@ static void setup_window() {
C_FG = 0x33ff33;
C_HEAD = 0x99ff99;
C_FOOD = 0x66ff66;
C_DIM = 0x0a3a0a;
C_DIM = 0x2f9f2f;
XSelectInput(dpy, win, KeyPressMask | StructureNotifyMask | ExposureMask);
XMapWindow(dpy, win);