#include<conio.h> #include<graphics.h> #include<stdio.h> #include<dos.h> int main(void) { int x=200,y=200; char c; int gdriver=DETECT,gmode; initgraph(&gdriver,&gmode,""); rectangle(20,460,600,20); setfillstyle(1,BLACK); do{ c=getch(); switch(c) { case 72: setcolor(BLACK); outtextxy(x,y,"*"); setcolor(RED); outtextxy(x,y-5,"*"); y-=5; break; case 75: setcolor(BLACK); outtextxy(x,y,"*"); setcolor(RED); outtextxy(x-5,y,"*"); x-=5; break; case 77: setcolor(BLACK); outtextxy(x,y,"*"); setcolor(RED); outtextxy(x+5,y,"*"); x+=5; break; case 80: setcolor(BLACK); outtextxy(x,y,"*"); setcolor(RED); outtextxy(x,y+5,"*"); y+=5; break; } }while( c!=27 && x>20 && x<600 && y>20 && y<460); return(0); }
|