在我的程序中,我试图制作一个滚动的字符数组,我有允许它滚动的部分,但我如何才能让它离开 map ,而不是沿着一条线,它会重置。您可能需要尝试我的代码才能明白我的意思。另外,我可以在轮廓框不动的地方做吗?这是我的代码:
#include <iostream>
#include <windows.h>
using namespace std;
char movingPicture[6][55];
void text(int, int, int);
int main()
{
int AxisX = 0;
memcpy (movingPicture, picture, sizeof(picture));
while(true)
{
for (int y = 0; y < 6; y++) {
for (int x = 0; x < 55; x++) {
text(AxisX+x, 5+y, 15); cout << movingPicture[y][x]; }
}
AxisX++;
Sleep(50);
}
}
最佳答案
text(AxisX+x, 5+y, 15); cout << movingPicture[y][x];
试试怎么样
text( (AxisX+x) % windowWidth, 5+y, 15); cout << movingPicture[y][x];
哪里windowWidth
窗口一行可显示的字符数是多少?这应该会导致图像从左向右滚动等等...
关于C++ 滚动字符数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30419245/