fix(games): correct Tetris rotation, fix input/render lag, visible window frame

- Tetris: replace pivot-based rotation with explicit 4-state SHAPES
  table (classic SRS-style) so rotation is correct and the O piece no
  longer drifts on rotate; keep simple wall-kick offsets.
- Both: render immediately after processing input (not only on gravity
  steps) so rotation/movement is no longer laggy.
- Both: draw the window frame inset by 2-3px (double line) so the right
  and bottom edges are actually visible instead of clipped at the edge.
This commit is contained in:
Luxferre
2026-10-23 15:47:30 +03:00
parent 6bf4139263
commit 1dd9fac313
6 changed files with 38 additions and 28 deletions
+6 -2
View File
@@ -219,7 +219,8 @@ static void render() {
// frame the whole window (right/bottom edges too)
XSetForeground(dpy, gc, C_DIM);
XDrawRectangle(dpy, back, gc, 0, 0, winW - 1, winH - 1);
XDrawRectangle(dpy, back, gc, 2, 2, winW - 4, winH - 4);
XDrawRectangle(dpy, back, gc, 3, 3, winW - 6, winH - 6);
// food
if (foodx >= 0) {
@@ -363,6 +364,7 @@ int main() {
FD_ZERO(&fds);
FD_SET(xfd, &fds);
int r = select(xfd + 1, &fds, nullptr, nullptr, &tv);
bool dirty = false;
if (r > 0) {
XEvent e;
while (XPending(dpy)) {
@@ -371,13 +373,15 @@ int main() {
if (!running) break;
}
if (!running) break;
dirty = true;
}
if (running && now_ms() >= nextTick) {
if (state == PLAYING) step();
if (state == PLAYING) nextTick = now_ms() + speed;
else nextTick = now_ms() + 80; // keep loop responsive while paused/over
render();
dirty = true;
}
if (dirty) render();
}
XFreeGC(dpy, gc);