Exemplo n.º 1
0
Arquivo: comm.c Projeto: gsrr/Python
static void recvnext()
{
	struct tetr next;
	char s[2];
	char *p = tetrom_seq;
	if (!p || !readbytes(s, 2) || s[1] > 6)
		return;
	switch (*s) {
	case '2':
		p += 2;
	case '1':
		break;
	default:
		return;
	}
	if (*p != 0x7F)
		p++;
	else {
		gettetrom(&next, s[1]);
		drawnext(game->player+(*s=='2'), &next);
		if (game->next)
		    *game->next = next;
	}
	*p = s[1];
}
Exemplo n.º 2
0
/* This show the current status of the game */
static void showstatus(engine_t *engine) {
    static const int shapenum[NUMSHAPES] = { 4, 6, 5, 1, 0, 3, 2 };
    char tmp[MAXDIGITS + 1];
    int i,sum = getsum ();
    out_setattr(ATTR_OFF);
    out_setcolor(COLOR_WHITE,COLOR_BLACK);
    out_gotoxy(1,YTOP + 1);   out_printf ("Your level: %d",level);
    out_gotoxy(1,YTOP + 2);   out_printf ("Full lines: %d",engine->status.droppedlines);
    out_gotoxy(2,YTOP + 4);   out_printf ("Score");
    out_setattr(ATTR_BOLD);
    out_setcolor(COLOR_YELLOW,COLOR_BLACK);
    out_printf("  %d",GETSCORE (engine->score));
    if (shownext) { 
        drawnext(engine->nextshape,3,YTOP + 22);
    }
    out_setattr(ATTR_OFF);
    out_setcolor(COLOR_WHITE,COLOR_BLACK);
    out_gotoxy(out_width () - MAXDIGITS - 12,YTOP + 1);
    out_printf("STATISTICS");
    out_setcolor(COLOR_BLACK,COLOR_MAGENTA);
    out_gotoxy(out_width () - MAXDIGITS - 17,YTOP + 3);
    out_printf("      ");
    out_gotoxy(out_width () - MAXDIGITS - 17,YTOP + 4);
    out_printf("  ");
    out_setcolor(COLOR_MAGENTA,COLOR_BLACK);
    out_gotoxy(out_width () - MAXDIGITS - 3,YTOP + 3);
    out_putch('-');
    snprintf(tmp,MAXDIGITS + 1,"%d",shapecount[shapenum[0]]);
    out_gotoxy(out_width () - strlen (tmp) - 1,YTOP + 3);
    out_printf("%s",tmp);
    out_setcolor(COLOR_BLACK,COLOR_RED);
    out_gotoxy(out_width () - MAXDIGITS - 13,YTOP + 5);
    out_printf("        ");
    out_setcolor(COLOR_RED,COLOR_BLACK);
    out_gotoxy(out_width () - MAXDIGITS - 3,YTOP + 5);
    out_putch('-');
    snprintf(tmp,MAXDIGITS + 1,"%d",shapecount[shapenum[1]]);
    out_gotoxy(out_width () - strlen (tmp) - 1,YTOP + 5);
    out_printf("%s",tmp);
    out_setcolor(COLOR_BLACK,COLOR_WHITE);
    out_gotoxy(out_width () - MAXDIGITS - 17,YTOP + 7);
    out_printf("      ");
    out_gotoxy(out_width () - MAXDIGITS - 13,YTOP + 8);
    out_printf("  ");
    out_setcolor(COLOR_WHITE,COLOR_BLACK);
    out_gotoxy(out_width () - MAXDIGITS - 3,YTOP + 7);
    out_putch('-');
    snprintf(tmp,MAXDIGITS + 1,"%d",shapecount[shapenum[2]]);
    out_gotoxy(out_width () - strlen (tmp) - 1,YTOP + 7);
    out_printf("%s",tmp);
    out_setcolor(COLOR_BLACK,COLOR_GREEN);
    out_gotoxy(out_width () - MAXDIGITS - 9,YTOP + 9);
    out_printf("    ");
    out_gotoxy(out_width () - MAXDIGITS - 11,YTOP + 10);
    out_printf("    ");
    out_setcolor(COLOR_GREEN,COLOR_BLACK);
    out_gotoxy(out_width () - MAXDIGITS - 3,YTOP + 9);
    out_putch('-');
    snprintf(tmp,MAXDIGITS + 1,"%d",shapecount[shapenum[3]]);
    out_gotoxy(out_width () - strlen (tmp) - 1,YTOP + 9);
    out_printf("%s",tmp);
    out_setcolor(COLOR_BLACK,COLOR_CYAN);
    out_gotoxy(out_width () - MAXDIGITS - 17,YTOP + 11);
    out_printf("    ");
    out_gotoxy(out_width () - MAXDIGITS - 15,YTOP + 12);
    out_printf("    ");
    out_setcolor(COLOR_CYAN,COLOR_BLACK);
    out_gotoxy(out_width () - MAXDIGITS - 3,YTOP + 11);
    out_putch('-');
    snprintf(tmp,MAXDIGITS + 1,"%d",shapecount[shapenum[4]]);
    out_gotoxy(out_width () - strlen (tmp) - 1,YTOP + 11);
    out_printf("%s",tmp);
    out_setcolor(COLOR_BLACK,COLOR_BLUE);
    out_gotoxy(out_width () - MAXDIGITS - 9,YTOP + 13);
    out_printf("    ");
    out_gotoxy(out_width () - MAXDIGITS - 9,YTOP + 14);
    out_printf("    ");
    out_setcolor(COLOR_BLUE,COLOR_BLACK);
    out_gotoxy(out_width () - MAXDIGITS - 3,YTOP + 13);
    out_putch('-');
    snprintf(tmp,MAXDIGITS + 1,"%d",shapecount[shapenum[5]]);
    out_gotoxy(out_width () - strlen (tmp) - 1,YTOP + 13);
    out_printf("%s",tmp);
    out_setattr(ATTR_OFF);
    out_setcolor(COLOR_BLACK,COLOR_YELLOW);
    out_gotoxy(out_width () - MAXDIGITS - 17,YTOP + 15);
    out_printf("      ");
    out_gotoxy(out_width () - MAXDIGITS - 15,YTOP + 16);
    out_printf("  ");
    out_setcolor(COLOR_YELLOW,COLOR_BLACK);
    out_gotoxy(out_width () - MAXDIGITS - 3,YTOP + 15);
    out_putch('-');
    snprintf(tmp,MAXDIGITS + 1,"%d",shapecount[shapenum[6]]);
    out_gotoxy(out_width () - strlen (tmp) - 1,YTOP + 15);
    out_printf("%s",tmp);
    out_setcolor(COLOR_WHITE,COLOR_BLACK);
    out_gotoxy(out_width () - MAXDIGITS - 17,YTOP + 17);
    for (i = 0; i < MAXDIGITS + 16; i++) {
        out_putch ('-');
    }
    out_gotoxy(out_width () - MAXDIGITS - 17,YTOP + 18);
    out_printf("Sum          :");
    snprintf(tmp,MAXDIGITS + 1,"%d",sum);
    out_gotoxy(out_width () - strlen (tmp) - 1,YTOP + 18);
    out_printf("%s",tmp);
    out_gotoxy(out_width () - MAXDIGITS - 17,YTOP + 20);
    for (i = 0; i < MAXDIGITS + 16; i++) {
        out_putch (' ');
    }
    out_gotoxy(out_width () - MAXDIGITS - 17,YTOP + 20);
    out_printf("Score ratio  :");
    snprintf(tmp,MAXDIGITS + 1,"%d",GETSCORE (engine->score) / sum);
    out_gotoxy(out_width () - strlen (tmp) - 1,YTOP + 20);
    out_printf("%s",tmp);
    out_gotoxy(out_width () - MAXDIGITS - 17,YTOP + 21);
    for (i = 0; i < MAXDIGITS + 16; i++) {
        out_putch (' ');
    }
    out_gotoxy(out_width () - MAXDIGITS - 17,YTOP + 21);
    out_printf("Efficiency   :");
    snprintf(tmp,MAXDIGITS + 1,"%d",engine->status.efficiency);
    out_gotoxy(out_width () - strlen (tmp) - 1,YTOP + 21);
    out_printf("%s",tmp);
}