# include <iostream>
# include <conio.h>
#include <graphics.h>
using namespace std;
int main()
{
initgraph(680,480);
int x=300;
int y=200;
char ch;
do
{
cleardevice();
line(100,100,600,100);
line(100,100,100,400);
line(600,100,600,400);
line(100,400,600,400);
circle(x,y,5);
ch = getch();
if ('a'==ch)
{
if (x >= 115)
{
x = x - 10;
}
}
else if ('w'==ch)
{
if (y >= 115)
{
y = y - 10;
}
}
else if ('d'==ch)
{
if (x <= 585)
{
x = x + 10;
}
}
else if ('s'==ch)
{
if (y <= 385)
{
y = y + 10;
}
}
}while(1);
getch();
closegraph();
return 0;
}
总结:
怎么这么少的代码额,希望不要走弯路了~~~
谢谢前辈们的支持~~~
加油~~~