Code: #include <conio.h> #include <stdio.h> #define ARR 72 #define ABJ 80 #define DER 77 #define IZQ 75 int main() { int x=1,y=1; int c; char AMostrar=16; do{ clrscr(); gotoxy(x,y); printf("%c",AMostrar); c=getch(); switch(c) { case ARR: y-=1; if(y<1)y=1; AMostrar=30; break; case ABJ: y+=1; AMostrar=31; break; case IZQ: x-=1; if(x<1)x=1; AMostrar=17; break; case DER: x+=1; if(x>80)x=80; AMostrar=16; break; } }while(c!='0'); return 0; }
Code: #include <stdio.h> #include <conio.h> #include <dos.h> void main() { clrscr(); int x,x2; do { for (x=1; x<20; x++) { if (kbhit())break; gotoxy(x,15); printf ("*"); x2=x-1; gotoxy(x2,15); printf (" "); delay(10); } for (;x>1;x--) { if (kbhit())break; gotoxy(x,15); printf("*"); x2=x+1; gotoxy(x2,15); printf(" "); delay(10); } } while (!kbhit()); }