最近期末,复习去了,没有仔细思考。。。
不过我写了一段,虽然和我想的不太一样,但勉强吧。。。
#include <graphics.h>
#include <conio.h>
#define SIZE 50
int main()
{
initgraph(640, 480);
HWND hwnd = GetHWnd();
SetWindowText(hwnd, "跟屁虫");
MOUSEMSG m;
int t = 0;
int i;
int time[SIZE] = { 0 };
int flag[SIZE] = { 0 };
int place[SIZE][2];
while (1)
{
m = GetMouseMsg();
if (m.uMsg == WM_RBUTTONUP)
break;
if (m.uMsg == WM_MOUSEMOVE)
{
putpixel(m.x, m.y, GREEN);
place[t][0] = m.x;
place[t][1] = m.y;
flag[t] = 1;
t = (t + 1) % SIZE;
}
for (i = 0; i < SIZE; i++)
{
if (flag[i])
time[i]++;
if (time[i] == 20)
{
time[i] = 0;
flag[i] = 0;
putpixel(place[i][0], place[i][1], BLACK);
}
}
}
closegraph();
}
@yangw80