Example #1
0
static void
DisplayTiles(void)
{
    int Line, peg, SlotNo;
    char TileBuf[BUFSIZ];

    erase();
    MvAddStr(1, 24, "T O W E R S   O F   H A N O I");
    MvAddStr(3, 34, "SJR 1990");
    MvPrintw(19, 5, "Moves : %d", NMoves);
    (void) attrset(A_REVERSE);
    MvAddStr(BASELINE, 8,
	     "                                                               ");

    for (Line = TOPLINE; Line < BASELINE; Line++) {
	MvAddCh(Line, LEFTPEG, ' ');
	MvAddCh(Line, MIDPEG, ' ');
	MvAddCh(Line, RIGHTPEG, ' ');
    }
    MvAddCh(BASELINE, LEFTPEG, '1');
    MvAddCh(BASELINE, MIDPEG, '2');
    MvAddCh(BASELINE, RIGHTPEG, '3');
    (void) attrset(A_NORMAL);

    /* Draw tiles */
    for (peg = 0; peg < NPEGS; peg++) {
	for (SlotNo = 0; SlotNo < Pegs[peg].Count; SlotNo++) {
	    size_t len = Pegs[peg].Length[SlotNo];
	    if (len < sizeof(TileBuf) - 1 && len < (size_t) PegPos[peg]) {
		memset(TileBuf, ' ', len);
		TileBuf[len] = '\0';
		if (has_colors())
		    (void) attrset((attr_t) COLOR_PAIR(LENTOIND(len)));
		else
		    (void) attrset(A_REVERSE);
		MvAddStr(BASELINE - (SlotNo + 1),
			 (PegPos[peg] - (int) len / 2),
			 TileBuf);
	    }
	}
    }
    (void) attrset(A_NORMAL);
    refresh();
}
Example #2
0
File: haino.c Project: shixv/test
    static void
DisplayTiles(void)
{
    int Line, peg, SlotNo;
    char TileBuf[BUFSIZ];
    erase();
    init_pair(20,COLOR_MAGENTA,COLOR_BLACK);
    attrset(COLOR_PAIR(20)|A_BOLD);
    mvaddstr(1, 25,"汉     诺     塔     游     戏");
    attrset(A_NORMAL);
    mvprintw(18, 30, "当前步数 : ");
    init_pair(21,COLOR_RED,COLOR_BLACK);
    attrset(COLOR_PAIR(21)|A_BOLD);
    mvprintw(18,41,"%d",NMoves);
    attrset(A_NORMAL);
    attrset(A_REVERSE);
    mvaddstr(BASELINE, 8,
            "                                                               ");
    for (Line = TOPLINE; Line < BASELINE; Line++) {
        mvaddch(Line, LEFTPEG, ' ');
        mvaddch(Line, MIDPEG, ' ');
        mvaddch(Line, RIGHTPEG, ' ');
    }
    mvaddch(BASELINE, LEFTPEG, '1');
    mvaddch(BASELINE, MIDPEG, '2');
    mvaddch(BASELINE, RIGHTPEG, '3');
    attrset(A_NORMAL);

    for (peg = 0; peg < NPEGS; peg++) {
        for (SlotNo = 0; SlotNo < Pegs[peg].Count; SlotNo++) {
            memset(TileBuf, ' ', Pegs[peg].Length[SlotNo]);
            TileBuf[Pegs[peg].Length[SlotNo]] = '\0';
            if (has_colors())
                attrset(COLOR_PAIR(LENTOIND(Pegs[peg].Length[SlotNo])));
            else
                attrset(A_REVERSE);
            mvaddstr(BASELINE - (SlotNo + 1),
                    (int) (PegPos[peg] - Pegs[peg].Length[SlotNo] / 2),
                    TileBuf);
        }
    }
    attrset(A_NORMAL);
    refresh();
}
Example #3
0
static void
DisplayTiles(void)
{
    int Line, peg, SlotNo;
    char TileBuf[BUFSIZ];

    erase();
    mvaddstr(1, 24, "T O W E R S   O F   H A N O I");
    mvaddstr(3, 34, "SJR 1990");
    mvprintw(19, 5, "Moves : %d", NMoves);
    attrset(A_REVERSE);
    mvaddstr(BASELINE, 8,
	     "                                                               ");

    for (Line = TOPLINE; Line < BASELINE; Line++) {
	mvaddch(Line, LEFTPEG, ' ');
	mvaddch(Line, MIDPEG, ' ');
	mvaddch(Line, RIGHTPEG, ' ');
    }
    mvaddch(BASELINE, LEFTPEG, '1');
    mvaddch(BASELINE, MIDPEG, '2');
    mvaddch(BASELINE, RIGHTPEG, '3');
    attrset(A_NORMAL);

    /* Draw tiles */
    for (peg = 0; peg < NPEGS; peg++) {
	for (SlotNo = 0; SlotNo < Pegs[peg].Count; SlotNo++) {
	    memset(TileBuf, ' ', Pegs[peg].Length[SlotNo]);
	    TileBuf[Pegs[peg].Length[SlotNo]] = '\0';
	    if (has_colors())
		attrset(COLOR_PAIR(LENTOIND(Pegs[peg].Length[SlotNo])));
	    else
		attrset(A_REVERSE);
	    mvaddstr(BASELINE - (SlotNo + 1),
		     (int) (PegPos[peg] - Pegs[peg].Length[SlotNo] / 2),
		     TileBuf);
	}
    }
    attrset(A_NORMAL);
    refresh();
}