Linux终端动画 - 最好的方式来延缓“框架”的印刷(C语言) [英] linux terminal animation - best way to delay printing of 'frame' (in C)
问题描述
我工作的一个简单的傍克隆的终端和需要一种方法来推迟框架的打印。
I'm working on a simple pong clone for the terminal and need a way to delay the printing of a 'frame'.
我有一个二维阵列
screen[ROWS][COLUMNS]
和打印屏幕的功能
and a function that prints the screen
void printScreen() {
int i = 0;
int j;
while(i < ROWS) {
j = 0;
while(j < COLUMNS) {
printf("%c", screen[i][j]);
j++;
}
i++;
}
}
看来,当我
printScreen();
usleep(1000000);
printScreen();
它将睡眠
执行的在的 PRINTSCREEN()
。
在终端上做这种类型的动画任何提示将是更AP preciated。也许我这样做是完全错误的。它是如何与ASCII电影这样完成一>
Any tips for doing this type of animation on the terminal would be much appreciated. Maybe I'm doing this completely wrong. How is it done with ASCII movies like this?
修改我跟ncurses的打算。谢谢两位的意见。
EDIT I'm going with ncurses. Thank you both for the suggestion.
在Ubuntu sudo的性向安装好libncurses5-dev的
和 -lncurses
编译。
On Ubuntu sudo aptitude install libncurses5-dev
and compile with -lncurses
.
推荐答案
ASCII电影都用的aalib这就像一个图形显示驱动程序完成。大多数人发展完全成熟的控制台应用程序和游戏使用诅咒框架或类似的ncurses版本的它。要去这条路线唯一真正的限制是你必须要充分ptty(你不能把它的一部分)。
Ascii movies are done with aalib which works like a graphics display driver. Most people developing full fledged console apps and games use the curses framework or a version of it like ncurses. The one real restriction of going that route is you have to want the full ptty (you can't take part of it).
这篇关于Linux终端动画 - 最好的方式来延缓“框架”的印刷(C语言)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!