Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/tetris Center game board on screen. OK from christos@.



details:   https://anonhg.NetBSD.org/src/rev/3f50d6d88d02
branches:  trunk
changeset: 343919:3f50d6d88d02
user:      nat <nat%NetBSD.org@localhost>
date:      Thu Mar 03 21:38:55 2016 +0000

description:
Center game board on screen.  OK from christos@.

diffstat:

 games/tetris/screen.c |  5 +++--
 games/tetris/tetris.c |  3 ++-
 games/tetris/tetris.h |  3 ++-
 3 files changed, 7 insertions(+), 4 deletions(-)

diffs (60 lines):

diff -r c1dcfdac8fb3 -r 3f50d6d88d02 games/tetris/screen.c
--- a/games/tetris/screen.c     Thu Mar 03 20:45:45 2016 +0000
+++ b/games/tetris/screen.c     Thu Mar 03 21:38:55 2016 +0000
@@ -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
@@ -197,6 +197,7 @@
                    MINCOLS, MINROWS);
                stop("");       /* stop() supplies \n */
        }
+       Offset = (Rows - D_LAST + D_FIRST - 2) / 2;
        if (tcgetattr(0, &oldtt) < 0)
                stop("tcgetattr() fails");
        newtt = oldtt;
@@ -360,7 +361,7 @@
                                        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) {
diff -r c1dcfdac8fb3 -r 3f50d6d88d02 games/tetris/tetris.c
--- a/games/tetris/tetris.c     Thu Mar 03 20:45:45 2016 +0000
+++ b/games/tetris/tetris.c     Thu Mar 03 21:38:55 2016 +0000
@@ -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
@@ -62,6 +62,7 @@
 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;
diff -r c1dcfdac8fb3 -r 3f50d6d88d02 games/tetris/tetris.h
--- a/games/tetris/tetris.h     Thu Mar 03 20:45:45 2016 +0000
+++ b/games/tetris/tetris.h     Thu Mar 03 21:38:55 2016 +0000
@@ -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
@@ -73,6 +73,7 @@
 #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.



Home | Main Index | Thread Index | Old Index