Exemple #1
0
void render(GameState *game)
{
    int h, w;
    int num_captured = 0;

    clear();
    getmaxyx(stdscr, h, w);

    for (int y = 0; y < h; y++)
        for (int x = 0; x < w; x++) {
            cchar_t pic;
            char_for_tile(get_tile(game, x, y), &pic);
            mvadd_wch(y, x, &pic);
        }

    for (size_t i = 0; i < game->num_letters; i++)
        if (game->letters[i].captured)
            mvaddch(SIZEY + 1, num_captured++, game->letters[i].val);
        else
            mvaddch(
                    game->letters[i].pos.y,
                    game->letters[i].pos.x,
                    game->letters[i].val
                   );

    mvaddch(game->player.pos.y, game->player.pos.x, '@');

    refresh();
}
Exemple #2
0
static int
MvAddCh(int y, int x, chtype ch)
{
    int code;
    cchar_t tmp_cchar;

    if (ConvertCh(ch, &tmp_cchar)) {
	code = mvadd_wch(y, x, &tmp_cchar);
    } else {
	code = mvaddch(y, x, ch);
    }
    return code;
}
void FalloutDisplay::print_attempts(int attempts, int delay_ms)
{
    cchar_t block_char;
    
    setcchar(&block_char, L"█ ", 0, COLOR_PAIR(1), NULL);
    
    std::string out = std::to_string(attempts) + " ATTEMPT(S) LEFT: ";
    
    // position needs to be made adjustable
    move_print_string_char_dly(out, 1, 4, delay_ms);
    
    for (int i = 0; i < (attempts * 2); i+= 2)
    {
        mvadd_wch(4, 20 + i, &block_char);
        usleep((delay_ms * 1000));
        refresh();
    }
}
Exemple #4
0
void Ncurses::output(const Life & life)
{
	erase();

	for(int x = 0; x < life.width; x++) {
		for(int y = 0; y < life.height; y += 2) {
			int up = life.map[x + (y) * life.width];
			int down = life.map[x + (y + 1) * life.width];

			cchar_t t;
			t.attr = up ? COLOR_PAIR(2) : COLOR_PAIR(1);
			t.chars[0] = (up == down) ? ' ' : 0x2584; // LOWER HALF BLOCK
			t.chars[1] = 0;

			mvadd_wch(y / 2, x, &t);
		}
	}

	refresh();
}