C++文字移动
#include <graphics.h>#include <conio.h>
void myouttextxy(int x, int y, LPCTSTR s)
{
static IMAGE tmp;
if (s == NULL)
{
putimage(x, y, &tmp);
}
else
{
int w = textwidth(s);
int h = textheight(s);
getimage(&tmp, x, y, w, h);
outtextxy(x, y, s);
}
}
void main()
{
TCHAR s[] = _T("祝大家梦想成真;祝Robin万寿无疆.");
initgraph(640, 480);
int w = textwidth(s);
int h = textheight(s);
IMAGE tmp;
for(int i = 0; i < 640; i++)
{
setlinecolor( HSLtoRGB((float)i, 1.0, 0.25) );
line(i, 0, i, 479);
}
setlinecolor(RED);
setbkmode(TRANSPARENT);
for(int j = 0; j < 600; j++)
{
myouttextxy(j, 100, s);
Sleep(20);
myouttextxy(j, 100, NULL);
}
_getch();
closegraph();
}