C++ 基于每秒的空间移动ascii对象

C++ 基于每秒的空间移动ascii对象,c++,flush,frame-rate,ascii-art,usleep,C++,Flush,Frame Rate,Ascii Art,Usleep,我正在尝试根据图片的垂直和水平速度移动图片。我知道,如果“图片”一词以每秒0.25个空格的速度在终端屏幕上移动,我会这样写: #include <iostream> #include <unistd.h> //for usleep() int main() { int pos = 0; screen_clear(); //clears the terminal screen for (pos = 0; pos <

我正在尝试根据图片的垂直和水平速度移动图片。我知道,如果“图片”一词以每秒0.25个空格的速度在终端屏幕上移动,我会这样写:

#include <iostream>
#include <unistd.h> //for usleep()

int main()
{
        int pos = 0;

        screen_clear(); //clears the terminal screen
        for (pos = 0; pos < 30; pos++) {
                screen_home();
                for (int i = 0; i < pos; i++)
                        cout << " ";
                cout << "Picture";
                screen_home(); //moves the cursor to the top of the screen
                cout.flush();
                usleep(250000); 
                /* I'm not sure if this is the right integer, but the usleep
                 * function takes microseconds as the input. */
        }
        return 0;
#包括
#包括//用于usleep()
int main()
{
int pos=0;
screen_clear();//清除终端屏幕
用于(pos=0;pos<30;pos++){
screen_home();
对于(int i=0;icout对于垂直移动,您需要打印
pos
'\n'
字符。在我的循环中,我将在哪里放置\n以及如何实现垂直移动的速度?(垂直和水平速度不同)“以每秒.25帧的速率在终端屏幕上移动”甚至没有意义…除非,你所说的“帧”实际上是指“角色位置”…你在第一次
screen\u home()之后这样做
呼叫,可能使用另一个
posY
来降低速度。要降低速度,只需在外循环中每隔n次这样做。特瓦尔伯格,是的,字符位置基本上就是我在这种情况下的意思。对于垂直移动,您需要打印
pos
'\n'
字符的数量。在我的循环中,我应该将字符放在哪里,我该如何放置执行垂直移动的速度?(垂直和水平速度不一样)“以每秒.25帧的速度在终端屏幕上移动”甚至没有意义…除非“帧”真正指的是“角色位置”…在第一次
屏幕主页()之后执行此操作
call,使用另一个
posY
可能。要降低速度,只需在外循环中每隔N次这样做。特瓦尔伯格,是的,在这种情况下,我的意思基本上是字符位置