Exemple #1
0
static void copy_same_height(int n)
{
	if (is_server)
		memcpy(player2.board, player1.board, 20*sizeof(uint_least32_t));
	else {
		memcpy(player1.board, player2.board, 20*sizeof(uint_least32_t));
		redrawboard(&player1, 19);
		sendboard(n);
	}
	sock_flags |= SAME_HEIGHT;
}
Exemple #2
0
static void removeline(int y) {
    int a, b;

    for (b=y; b>0; b--) {
        for (a=4; a<WIDTH+4; a++) {
            board[a][b] = board[a][b-1];
            boardcolors[a][b] = boardcolors[a][b-1];
        }
    }
    redrawboard(y);
}
Exemple #3
0
void drawgamescreen_1p()
{
	drawboard(1);
	refreshwin(0);
	if (game_paused)
		clearboard_paused();
	else
		redrawboard(&player1, 19);
	drawpanel_1p();
	print_top_scores();
	print_tetr_stats();
	refreshwin(WIN_PANEL);
}
Exemple #4
0
void refreshwin(int win)
{
	static int redraw;
	struct player *p;
	if (redraw)
		return;
#ifdef TWOPLAYER
	if ((win == 1 || win == 2) && !game_running) {
		p = &game->player[win-1];
#else
	if (win == 1 && !game_running) {
		p = &player1;
#endif
		redraw = 1;
		if (game_paused)
			redrawboard(p, 19);
		else
			redrawboard(p, 3);
		redraw = 0;
	}
	refreshscreen();
}

/* only used for clearing window showing next tetromino and game screen */
void clearwin(int win)
{
	int h;
	setwcurs(win, 0, 0);
	if (win >= WIN_NEXT)
		clearbox(0, 0, 8, 2);
	else {
		margin_x = 0;
		h = term_height;
		if (h < 24 && h > 21)
			h = 21;
		clearbox(0, 0, 0, h);
	}
}
Exemple #5
0
static void recvboard()
{
	char s[48];
	unsigned char *b = (unsigned char *) s;
	uint_least32_t row;
	int n, m = 0;
	int i = 20;
	int j;
	if (!readbytes(s, 1)) 
		return;
	n = *s;
	if (n < 1 || n > 12) {
		conn_broken(0);
		return;
	}
	if (!recvboard_read(s, n) || !tetrom_seq)
		return;
	if (!game->state)
		m = p1_height_lines();
	if (!player1.height && sock_flags & SAME_HEIGHT) {
		m = n;
		p1_lines_height(n);
	}
	while (n) {
		row = b[3];
		for (j = 2; j >= 0; j--) {
			row <<= 8;
			row |= b[j];
		}
		player2.board[--i] = row;
		b += 4;
		n--;
	}
	n = 20-i;
	if (n == m)
		copy_same_height(n);
	redrawboard(&player2, 19);
	if (!game_running)
		print_press_key();
}