Commit d4efc9c0 authored by Yağız Arda Gün 's avatar Yağız Arda Gün
Browse files

Initial commit

parents
#include <stdio.h>
#include <windows.h>
void display_border();
COORD c = {0, 0};
void setxy (int x, int y)
{
c.X = x; c.Y = y; // x ve y koordinatlarn 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 snrlyoruz
{
setxy(--batx,baty);
printf("===");
setxy(batx+3,baty);//yolu temizlemek iinn alana ayoruz
printf(" ");
}
}
if(ch2 == 77) //sa
{
if(batx<37)//topu sa duvarla snrlyoruz
{
setxy(++batx,baty);
printf("===");
setxy(batx-1,baty);//topun rotas iin boluk atyoruz
printf(" ");
}
}
if(ch2 == 72) //yukar
{
if(baty>6)
{
setxy(batx,--baty);
printf("===");
setxy(batx,baty+1);
printf(" ");
}
}
if(ch2 == 80) //aa
{
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 snr izgisi
setxy(10,5);
for(j=0; j<30; j++)
printf("%c", 223);
//alt snr cizgisi
setxy(10,15);
for(j=0; j<=30; j++)
printf("%c", 223);
//sol ve sa snr cizgileri
for(j=0; j<10; j++)
{
setxy(10,5+j);
printf("%c",219);
setxy(40,5+j);
printf("%c",219);
}
printf("\n");
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment