Skip to content

Commit

Permalink
Center game board on screen. OK from christos@.
Browse files Browse the repository at this point in the history
  • Loading branch information
nat committed Mar 3, 2016
1 parent 70122fc commit cfcc52d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions games/tetris/screen.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: screen.c,v 1.31 2015/11/06 19:53:37 christos Exp $ */
/* $NetBSD: screen.c,v 1.32 2016/03/03 21:38:55 nat Exp $ */

/*-
* Copyright (c) 1992, 1993
Expand Down Expand Up @@ -197,6 +197,7 @@ scr_set(void)
MINCOLS, MINROWS);
stop(""); /* stop() supplies \n */
}
Offset = (Rows - D_LAST + D_FIRST - 2) / 2;
if (tcgetattr(0, &oldtt) < 0)
stop("tcgetattr() fails");
newtt = oldtt;
Expand Down Expand Up @@ -360,7 +361,7 @@ scr_update(void)
putpad(exit_standout_mode);
cur_so = 0;
}
moveto(RTOD(j), CTOD(i));
moveto(RTOD(j + Offset), CTOD(i));
}
if (enter_standout_mode) {
if (so != cur_so) {
Expand Down
3 changes: 2 additions & 1 deletion games/tetris/tetris.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: tetris.c,v 1.31 2015/11/06 19:53:37 christos Exp $ */
/* $NetBSD: tetris.c,v 1.32 2016/03/03 21:38:55 nat Exp $ */

/*-
* Copyright (c) 1992, 1993
Expand Down Expand Up @@ -62,6 +62,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\
cell board[B_SIZE]; /* 1 => occupied, 0 => empty */

int Rows, Cols; /* current screen size */
int Offset; /* used to center board & shapes */

static const struct shape *curshape;
const struct shape *nextshape;
Expand Down
3 changes: 2 additions & 1 deletion games/tetris/tetris.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: tetris.h,v 1.14 2014/07/13 16:23:55 pgoyette Exp $ */
/* $NetBSD: tetris.h,v 1.15 2016/03/03 21:38:55 nat Exp $ */

/*-
* Copyright (c) 1992, 1993
Expand Down Expand Up @@ -73,6 +73,7 @@ extern cell board[B_SIZE]; /* 1 => occupied, 0 => empty */
#define MINCOLS 40

extern int Rows, Cols; /* current screen size */
extern int Offset; /* vert. offset to center board */

/*
* Translations from board coordinates to display coordinates.
Expand Down

0 comments on commit cfcc52d

Please sign in to comment.