fix(games): single playfield border, snake score in top strip, no soft-drop scoring, 239x295 window
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+9
-13
@@ -22,8 +22,8 @@
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
static const int WIN_W = 240;
|
||||
static const int WIN_H = 296;
|
||||
static const int WIN_W = 239;
|
||||
static const int WIN_H = 295;
|
||||
static const int COLS = 24;
|
||||
static const int ROWS = 28;
|
||||
|
||||
@@ -113,15 +113,16 @@ static unsigned long now_ms() {
|
||||
|
||||
static void compute_grid() {
|
||||
int m = 4;
|
||||
int topH = 16; // reserved status strip for SCORE/BEST
|
||||
int aw = winW - 2 * m;
|
||||
int ah = winH - 2 * m;
|
||||
int ah = winH - topH - m;
|
||||
cell = aw / COLS;
|
||||
if ((ah / ROWS) < cell) cell = ah / ROWS;
|
||||
if (cell < 4) cell = 4;
|
||||
gw = cell * COLS;
|
||||
gh = cell * ROWS;
|
||||
gx0 = (winW - gw) / 2;
|
||||
gy0 = (winH - gh) / 2;
|
||||
gy0 = topH + (ah - gh) / 2;
|
||||
}
|
||||
|
||||
static void place_food() {
|
||||
@@ -213,15 +214,10 @@ static void render() {
|
||||
XSetForeground(dpy, gc, C_BG);
|
||||
XFillRectangle(dpy, back, gc, 0, 0, winW, winH);
|
||||
|
||||
// playfield border
|
||||
// playfield border (single clean frame around the grid)
|
||||
XSetForeground(dpy, gc, C_DIM);
|
||||
XDrawRectangle(dpy, back, gc, gx0 - 1, gy0 - 1, gw + 2, gh + 2);
|
||||
|
||||
// frame the whole window (right/bottom edges too)
|
||||
XSetForeground(dpy, gc, C_DIM);
|
||||
XDrawRectangle(dpy, back, gc, 2, 2, winW - 4, winH - 4);
|
||||
XDrawRectangle(dpy, back, gc, 3, 3, winW - 6, winH - 6);
|
||||
|
||||
// food
|
||||
if (foodx >= 0) {
|
||||
XSetForeground(dpy, gc, C_FOOD);
|
||||
@@ -233,13 +229,13 @@ static void render() {
|
||||
XFillRectangle(dpy, back, gc, gx0 + snake[i][0] * cell, gy0 + snake[i][1] * cell, cell, cell);
|
||||
}
|
||||
|
||||
// score (top-left, small)
|
||||
// score (top status strip, clear of the playfield border)
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "SCORE %d", score);
|
||||
draw_text(gx0, 2, 1, C_DIM, buf);
|
||||
draw_text(gx0, 4, 1, C_DIM, buf);
|
||||
if (best > 0) {
|
||||
snprintf(buf, sizeof(buf), "BEST %d", best);
|
||||
draw_text(gx0 + gw - 11 * 6, 2, 1, C_DIM, buf);
|
||||
draw_text(gx0 + gw - 11 * 6, 4, 1, C_DIM, buf);
|
||||
}
|
||||
|
||||
if (state == PAUSED || state == GAMEOVER) {
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
static const int WIN_W = 240;
|
||||
static const int WIN_H = 296;
|
||||
static const int WIN_W = 239;
|
||||
static const int WIN_H = 295;
|
||||
static const int PCOLS = 10;
|
||||
static const int PROWS = 20;
|
||||
static const int CELL = 14;
|
||||
@@ -255,15 +255,10 @@ static void render() {
|
||||
XSetForeground(dpy, gc, C_BG);
|
||||
XFillRectangle(dpy, back, gc, 0, 0, winW, winH);
|
||||
|
||||
// playfield border
|
||||
// playfield border (single clean frame around the well)
|
||||
XSetForeground(dpy, gc, C_DIM);
|
||||
XDrawRectangle(dpy, back, gc, px0 - 1, py0 - 1, PCOLS * CELL + 2, PROWS * CELL + 2);
|
||||
|
||||
// frame the whole window (right/bottom edges too)
|
||||
XSetForeground(dpy, gc, C_DIM);
|
||||
XDrawRectangle(dpy, back, gc, 2, 2, winW - 4, winH - 4);
|
||||
XDrawRectangle(dpy, back, gc, 3, 3, winW - 6, winH - 6);
|
||||
|
||||
// settled blocks
|
||||
for (int x = 0; x < PCOLS; x++)
|
||||
for (int y = 0; y < PROWS; y++)
|
||||
@@ -381,7 +376,7 @@ static void handle_key(KeySym ks) {
|
||||
int cells[4][2];
|
||||
piece_cells(curType, curRot, cells);
|
||||
if (!collide(curX, curY + 1, cells)) {
|
||||
curY++; score += 1; if (score > best) best = score;
|
||||
curY++;
|
||||
} else {
|
||||
lock_piece();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user