void render_init(void) {
initscr(); // 启动 ncurses
cbreak(); // 禁用行缓冲
noecho(); // 不显示输入
keypad(stdscr, TRUE); // 启用方向键
curs_set(0); // 隐藏光标
start_color();
init_pair(1, COLOR_CYAN, -1); // I 方块
init_pair(2, COLOR_YELLOW, -1); // O 方块
}
void render_block(int x, int y, int color) {
attron(COLOR_PAIR(color));
mvaddch(y, x * 2, ACS_CKBOARD);
mvaddch(y, x * 2 + 1, ACS_CKBOARD);
attroff(COLOR_PAIR(color));
}
┌────────────────────┐ NEXT: HOLD:
│ │ ┌──┐ ┌──┐
│ ██████ │ │██│ │██│
│ ██ │ └──┘ └──┘
└────────────────────┘ SCORE: LEVEL:
下一课:调试技巧