我正在尝试根据其垂直和水平速度移动图片。据我所知,如果说“#34; Picture"要以每秒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;
我的问题是,如何实现垂直移位和/或负速度(向左移动而不是向右移动)?