发布网友 发布时间:2022-05-02 18:56
共3个回答
热心网友 时间:2023-10-09 06:01
曾经写过一个,好不容易找到了,给你吧#include <graphics.h>#include <stdio.h>#include <conio.h>#define R 40void main(){initgraph(640,480);int x=320, y=240;int a=40;setcolor(YELLOW);setfillstyle(GREEN);fillellipse(x,y,R,R);char c;c=getch();while(c!=27){cleardevice();while(c=='a'){x-=2;setcolor(YELLOW);setfillstyle(GREEN);fillellipse(x,y,R,R);Sleep(10);cleardevice();if(kbhit())c=getch();while(c!='a'&&c!='d'&&c!='s'&&c!='w'&&c!=27){x-=2;setcolor(YELLOW);setfillstyle(GREEN);fillellipse(x,y,R,R);Sleep(10);cleardevice();if(kbhit())c=getch();}}while(c=='d'){x+=2;setcolor(YELLOW);setfillstyle(GREEN);fillellipse(x,y,R,R);Sleep(10);cleardevice();if(kbhit())c=getch();while(c!='a'&&c!='d'&&c!='s'&&c!='w'&&c!=27){x+=2;setcolor(YELLOW);setfillstyle(GREEN);fillellipse(x,y,R,R);Sleep(10);cleardevice();if(kbhit())c=getch();}}while(c=='w'){y-=2;setcolor(YELLOW);setfillstyle(GREEN);fillellipse(x,y,R,R);Sleep(10);cleardevice();if(kbhit())c=getch();while(c!='a'&&c!='d'&&c!='s'&&c!='w'&&c!=27){y-=2;setcolor(YELLOW);setfillstyle(GREEN);fillellipse(x,y,R,R);Sleep(10);cleardevice();if(kbhit())c=getch();}}while(c=='s'){y+=2;setcolor(YELLOW);setfillstyle(GREEN);fillellipse(x,y,R,R);Sleep(10);cleardevice();if(kbhit())c=getch();while(c!='a'&&c!='s'&&c!='d'&&c!='w'&&c!=27){y+=2;setcolor(YELLOW);setfillstyle(GREEN);fillellipse(x,y,R,R);Sleep(10);cleardevice();if(kbhit())c=getch();}}热心网友 时间:2023-10-09 06:02
修改循环变量热心网友 时间:2023-10-09 06:02
碰壁反弹,