#include <iostream.h>
#include <conio.h>
#include <graphics.h>
#include <dos.h>
#include <stdlib.h>
int z[10][10],a,b;
void tabule()
{
int x=50 ,y=50;
setcolor(10);
for(int i=0;i<20;i++)
{
x=50;
for(int j=0;j<20;j++)
{
rectangle(x,y,x+30,y+30);
x+=30;
}
y+=30;
}
}
void wall()
{
randomize();
int x=55,y=55;
for(int i=0;i<20;i++)
{
x=55;
for(int j=0;j<50;j++)
{
z[i][j]=random(5);
if(z[i][j]==0)
{
setfillstyle(1,7);
floodfill(x,y,5);
}
if(z[i][j]==2)
{
setfillstyle(1,13);
floodfill(x,y,5);
}
if(z[i][j]==1)
{
setfillstyle(7,3);
floodfill(x,y,5);
setfillstyle(1,7);
}
x+=30;
}
y+=30;
}
for(i=0;i<20;i++)
{
for(int j=0;j<20;j++)
{
cout<<z[i][j];
}
cout<<' ';
}
int c,d;
while(1)
{
c=random(9);
d=random(9);
a=c;
b=d;
if(z[c][d]==0)
{
z[c][d]=3;
break;
}
}
if(z[c][d]==3)
{
setfillstyle(1,12);
floodfill(55+(c*30),55+(d*30),5);
}
}
void game()
{
int i=a,j=b;
int point=0;
int x,y;
int r=8;
setcolor(6);
x=95+(j*30);
y=95+(i*30);
circle(x,y,8);
while(x>=80 && x<=380 && y>=80 && y<=380)
{
setcolor(6);
circle(x,y,r);
setcolor(15);
outtextxy(450,195,"point:");
gotoxy(65,13);
cout<<point;
if(point==50)
{
clrscr();
setfillstyle(1,0);
settextstyle(0,0,6);
outtextxy(200,200,"GOOD");
getch();
exit(0);
}
if(kbhit())
{
char ch=getch();
{
if(ch==13)
exit(0);
if(ch==27)
{
clrscr();
//cleardevice();
randomize();
tabule();
wall();
game();
}
if(ch==0)
{
char b=getch();
{
if(b==72)
{
i-=1;
if(z[i][j]==0 || z[i][j]==4 || z[i][j]==2)
{
if(z[i][j]==2)
{
r+=1;
point+=10;
}
if(z[i][j]==0)
{
r=8;
}
setcolor(6);
y-=30;
circle(x,y,r);
z[i][j]+=6;
}
else
{
i+=1;
}
}
if(b==80)
{
i+=1;
if(z[i][j]==0 || z[i][j]==4 || z[i][j]==2)
{
if(z[i][j]==2)
{
r+=1;
point+=10;
}
if(z[i][j]==0)
{
r=8;
}
setcolor(6);
y+=30;
circle(x,y,r);
z[i][j]+=6;
}
else
{
i-=1;
}
}
if(b==77)
{
j+=1;
if(z[i][j]==0 || z[i][j]==4 || z[i][j]==2)
{
if(z[i][j]==2)
{
r+=1;
point+=10;
}
if(z[i][j]==0)
{
r=8;
}
setcolor(6);
x+=30;
circle(x,y,r);
z[i][j]+=6;
}
else
{
j-=1;
}
}
if(b==75)
{
j-=1;
if(z[i][j]==0 || z[i][j]==4 || z[i][j]==2)
{
if(z[i][j]==2)
{
r+=1;
point+=10;
}
if(z[i][j]==0)
{
r=8;
}
setcolor(6);
x-=30;
circle(x,y,r);
z[i][j]+=6;
}
else
{
j+=1;
}
}
}
}
}
}
for(int i=0;i<10;i++)
{
for(int j=0;j<10;j++)
{
if(z[i][j]==3)
break;
}
}
}
setcolor(7);
}
void main()
{
int d=0,m=0;
initgraph(&d,&m,"");
tabule();
wall();
game();
getch();
}
علاقه مندی ها (Bookmarks)