#include #include void display_border(); COORD c = {0, 0}; void setxy (int x, int y) { c.X = x; c.Y = y; // x ve y koordinatlarını belirliyoruz SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c); } int main() { int batx=15,baty=13, ballx=25, bally=7; int x=25, y=10, ch1, ch2, b; setxy(14,1); printf("...Topu Bul...") ; display_border(); setxy(batx, baty); printf("==="); setxy(ballx, bally); printf("%c",2); ch1 = getch(); ch2 = 0; if (ch1 == 0xE0) { while(ch2=getch()) { if(ch2 == 'X') exit(0); if(ch2 == 75)//sol { if(batx>11) //topu sol duvarla sınırlıyoruz { setxy(--batx,baty); printf("==="); setxy(batx+3,baty);//yolu temizlemek içinn alana açıyoruz printf(" "); } } if(ch2 == 77) //sağ { if(batx<37)//topu sağ duvarla sınırlıyoruz { setxy(++batx,baty); printf("==="); setxy(batx-1,baty);//topun rotası için boşluk atıyoruz printf(" "); } } if(ch2 == 72) //yukarı { if(baty>6) { setxy(batx,--baty); printf("==="); setxy(batx,baty+1); printf(" "); } } if(ch2 == 80) //aşağı { if(baty<14) { setxy(batx,++baty); printf("==="); setxy(batx,baty-1); printf(" "); } } if(batx==ballx-1 && baty==bally) { setxy(ballx-9,bally+4); printf("...tebriklerr..."); setxy(ballx-9,bally+5); printf(" ...Top bulundu.."); setxy(ballx-9,bally+6); printf(" ...Oyun bitti kaybettiniz.."); getch(); exit(0); } } } getch(); return 0; } void display_border() { int i, j; //üst sınır çizgisi setxy(10,5); for(j=0; j<30; j++) printf("%c", 223); //alt sınır cizgisi setxy(10,15); for(j=0; j<=30; j++) printf("%c", 223); //sol ve sağ sınır cizgileri for(j=0; j<10; j++) { setxy(10,5+j); printf("%c",219); setxy(40,5+j); printf("%c",219); } printf("\n"); }