Tetris

Check-in [12ab685ed3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Factor out random number generator
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:12ab685ed3ac73dfe5d32af16b6dfcbdfaa0cdd28a404a084c34cd5069d487bc
User & Date: ajv-899-334-8894@vsta.org 2008-10-26 17:42:30
Context
2008-10-26
18:02
Abstract out random number gen check-in: 2d84188e40 user: ajv-899-334-8894@vsta.org tags: trunk
17:42
Factor out random number generator check-in: 12ab685ed3 user: ajv-899-334-8894@vsta.org tags: trunk
17:42
Add random.c check-in: e130331ce3 user: ajv-899-334-8894@vsta.org tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tetris.h.

77
78
79
80
81
82
83




84
85
86
87
88
89
90
...
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
 * Translations from board coordinates to display coordinates.
 * As with board coordinates, display coordiates are zero origin.
 */
#define	RTOD(x)	((x) - 1)
#define	CTOD(x)	((x) * 2 + (((Cols - 2 * B_COLS) >> 1) - 1))





/*
 * A `shape' is the fundamental thing that makes up the game.  There
 * are 7 basic shapes, each consisting of four `blots':
 *
 *	X.X	  X.X		X.X
 *	  X.X	X.X	X.X.X	X.X	X.X.X	X.X.X	X.X.X.X
 *			  X		X	    X
................................................................................
 */
struct shape {
	int	rot;	/* index of rotated version of this shape */
	int	off[3];	/* offsets to other blots if center is at (0,0) */
};

extern const struct shape shapes[];
#define	randshape() (&shapes[random() % 7])

extern const struct shape *curshape;
extern const struct shape *nextshape;

/*
 * Shapes fall at a rate faster than once per second.
 *







>
>
>
>







 







|







77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
...
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
 * Translations from board coordinates to display coordinates.
 * As with board coordinates, display coordiates are zero origin.
 */
#define	RTOD(x)	((x) - 1)
#define	CTOD(x)	((x) * 2 + (((Cols - 2 * B_COLS) >> 1) - 1))

/* Our own interface into random number generation */
extern void init_random(void);
extern unsigned int get_random(void);

/*
 * A `shape' is the fundamental thing that makes up the game.  There
 * are 7 basic shapes, each consisting of four `blots':
 *
 *	X.X	  X.X		X.X
 *	  X.X	X.X	X.X.X	X.X	X.X.X	X.X.X	X.X.X.X
 *			  X		X	    X
................................................................................
 */
struct shape {
	int	rot;	/* index of rotated version of this shape */
	int	off[3];	/* offsets to other blots if center is at (0,0) */
};

extern const struct shape shapes[];
#define	randshape() (&shapes[get_random() % 7])

extern const struct shape *curshape;
extern const struct shape *nextshape;

/*
 * Shapes fall at a rate faster than once per second.
 *