mvprintw/mvaddch (pdcurses) 仅在 getch() 之后打印文本(即使它没有以任何方式连接并且 getch 在分离线程中)。
// MAIN WHILE (Strong simplification for debag)
do
{
//printf(" [%d] ", exit_flag);
char player_action = getch();
//render_player_info();
//printf("%d ", player_x);
mvprintw(1, player_x, "%d ", player_y);
mvaddch(1, player_y, 'C');
//Sleep(1);
}
while(exit_flag == 0);
// CODE BLOCK FROM LAUNCH FUNC (Main while start after thread detach)
int res;
pthread_t thread_render_engine;
void *thread_func_render_engine(void * arg)
{
int count = 0;
do
{
count++;
printf(" F%d ", count);
mvprintw(count/10 + 1, count, "P");
mvaddch(count/10 + 2, count, 'A');
render_player_info();
Sleep(1000);
} while (!exit_flag);
pthread_exit(NULL);
}
res = pthread_create (&thread_render_engine, NULL, thread_func_render_engine, NULL);
if (res != 0) {
mvprintw(29, 0, "main error: can't create thread, status = %d\n", res);
exit(-10);
}
res = pthread_detach(thread_render_engine);
if (res != 0) {
mvprintw(29, 0, "main error: can't detach thread, status = %d\n", res);
exit(-11);
}
我试图从 amin dowhile 中删除 getch 并且默认 printf 在没有 getch 的情况下工作,但不是 mvprintw/mvaddch