Exemplo n.º 1
0
/*
 * refresh game area
 */
static void refresh(void)
{
	struct console * con = get_console_stdout();
	s32_t w, h;
	s32_t x, y, xp, yp;

	if(!con)
		return;

	for(y=0; y < GAME_AREA_HEIGHT; y++)
	{
		if(map.dirty[y] == FALSE)
			continue;

		for(x=0; x < GAME_AREA_WIDTH; x++)
		{
			console_getwh(con, &w, &h);
			xp = (w - GAME_AREA_WIDTH) / 2;
			yp = (h - GAME_AREA_HEIGHT) / 2;
			console_gotoxy(con, xp + x, yp + y);
			if(map.screen[x][y] != TCOLOR_BLACK)
				console_setcolor(con, TCOLOR_BLACK, map.screen[x][y]);
			else
				console_setcolor(con, TCOLOR_WHITE, TCOLOR_BLACK);
			console_putcode(con, UNICODE_SPACE);
		}
		map.dirty[y] = FALSE;
    }
}
Exemplo n.º 2
0
bool_t console_rect(struct console * console, u32_t hline, u32_t vline, u32_t lt, u32_t rt, u32_t lb, u32_t rb, u32_t x, u32_t y, u32_t w, u32_t h)
{
	s32_t width, height;

	if(console && console->putcode)
	{
		if(!console_getwh(console, &width, &height))
			return FALSE;

		if(x < 0 || y < 0 || w < 2 || h < 2)
			return FALSE;

		if(x >= width || y >= height)
			return FALSE;

		if(x + w - 1 >= width)
			return FALSE;

		if(y + h - 1 >= height)
			return FALSE;

		console_gotoxy(console, x, y);
		console_putcode(console, lt);

		console_gotoxy(console, x + w - 1, y);
		console_putcode(console, rt);

		console_gotoxy(console, x, y + h - 1);
		console_putcode(console, lb);

		console_gotoxy(console, x + w - 1, y + h - 1);
		console_putcode(console, rb);

		console_hline(console, hline, x + 1, y, w - 1 - 1);
		console_hline(console, hline, x + 1, y + h - 1, w - 1 - 1);
		console_vline(console, vline, x, y + 1, h - 1 - 1);
		console_vline(console, vline, x + w - 1, y + 1, h - 1 - 1);

		return TRUE;
	}

	return FALSE;
}