diff --git a/overlay/rootfs/usr/bin/tetris b/overlay/rootfs/usr/bin/tetris index 10d3044..6edb6a0 100755 Binary files a/overlay/rootfs/usr/bin/tetris and b/overlay/rootfs/usr/bin/tetris differ diff --git a/prebuilt/games/usr/bin/tetris b/prebuilt/games/usr/bin/tetris index 10d3044..6edb6a0 100755 Binary files a/prebuilt/games/usr/bin/tetris and b/prebuilt/games/usr/bin/tetris differ diff --git a/src/games/tetris.cpp b/src/games/tetris.cpp index 1a6e8e7..34f2781 100644 --- a/src/games/tetris.cpp +++ b/src/games/tetris.cpp @@ -279,27 +279,40 @@ static void render() { } } + // vertical separator line between the playfield and the side panel + int sepX = px0 + PCOLS * CELL + 6; + XSetForeground(dpy, gc, C_FG); + XDrawLine(dpy, back, gc, sepX, py0, sepX, py0 + PROWS * CELL); + // side panel int sx = px0 + PCOLS * CELL + 12; draw_text(sx, py0, 1, C_DIM, "NEXT"); + // framed preview box for the next piece + int boxY = py0 + 10; + int boxH = 48; + XSetForeground(dpy, gc, C_DIM); + XDrawRectangle(dpy, back, gc, sx, boxY, winW - sx - 4, boxH); int nc[4][2]; piece_cells(nextType, 0, nc); int minx = 4, miny = 4, maxx = -1, maxy = -1; for (int i = 0; i < 4; i++) { minx = nc[i][0] < minx ? nc[i][0] : minx; - miny = nc[i][1] < miny ? nc[i][1] : miny; + miny = nc[i][1] < miny ? miny : miny; maxx = nc[i][0] > maxx ? nc[i][0] : maxx; - maxy = nc[i][1] > maxy ? nc[i][1] : maxy; + maxy = nc[i][1] > maxy ? maxy : maxy; } - int pcell = 6; - int nx0 = sx + 2, ny0 = py0 + 10; + int pcell = 11; // larger next-piece preview + int pcols = maxx - minx + 1; + int prows = maxy - miny + 1; + int nx0 = sx + ((winW - sx - 4) - pcols * pcell) / 2; + int ny0 = boxY + (boxH - prows * pcell) / 2; XSetForeground(dpy, gc, C_HEAD); for (int i = 0; i < 4; i++) { int cx = nx0 + (nc[i][0] - minx) * pcell; int cy = ny0 + (nc[i][1] - miny) * pcell; XFillRectangle(dpy, back, gc, cx, cy, pcell, pcell); } - int ty = py0 + 60; + int ty = boxY + boxH + 6; char buf[32]; snprintf(buf, sizeof(buf), "SCORE %d", score); draw_text(sx, ty, 1, C_DIM, buf); snprintf(buf, sizeof(buf), "LINES %d", lines); draw_text(sx, ty + 9, 1, C_DIM, buf);