#include
#include
#include
#include
#include
#include
#include
#define n 25
void start(void);
void end(void);
void rhits(void);
void yhits(void);
void phits(void);
char *msg;
void *ball, *ball1, *ball2, *gun, *bomb[n];
void *rhrt[n], *yhrt[n], *phrt[n];
int rflag[n], yflag[n], pflag[n];
int rx[n], ry[n], yx[n], yy[n], px[n], py[n];
int j, life = 3;
int rin=0, yin=0, pin=0;
unsigned int size,size1,size2,size3,size4;
int count = 0, r = 10, bct=0;
int nohits = 0, i;
int ats = 0;
int xend = 400, yend = 450;
char che = 3, ch;
int flag = 1, x = 5, gx = 4, hitflag[n];
int speed = 1, hity[n], hitx[n];
int x1 = 200, x2 = 377;
int ti=500;
int flag1 = 1, flag2 = 1;
int rhit = 0, yhit = 0, phit = 0;
struct time t;
void main(void)
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "..//bgi");
sprintf(msg,"%c",che);
setcolor(RED);
settextstyle(0,0,30);
outtextxy(getmaxx()/2-130,getmaxy()/2-100,msg);
setcolor(WHITE);
settextstyle(0,0,0);
outtextxy(getmaxx()/2-100,getmaxy()/2-50,"Heart Break Kid Game");
getch();
cleardevice();
start();
for(i=0;i=15)
gx -= 15;
}
else if(ch==77)
{
if(gx<=xend-25)
gx += 15;
}
putimage(gx,yend-14,gun,XOR_PUT);
if(ch==72&&life>0)
{
ats += 1;
int remflag = 0;
for(i=0;i1)
{
hitflag[i]= 1;
remflag = 1;
hitx[i] = gx + 8 - 3;
hity[i] = yend - 14 - 15;
putimage(hitx[i],hity[i],bomb[i],XOR_PUT);
break;
}
}
if(remflag==0)
{
for(i=0;i=x&&hitx[i]<=x+20&&hity[i]>=5&&hity[i]<=25)
{
rhits();
count += 3;
rhit += 1;
hitflag[i] = 2;
}
if(hitx[i]>=x1&&hitx[i]<=x1+20&&hity[i]>=150&&hity[i]<=170)
{
yhits();
count += 2;
yhit+=1;
hitflag[i] = 2;
}
if(hitx[i]>=x2&&hitx[i]<=x2+20&&hity[i]>=250&&hity[i]<=270)
{
phits();
count += 1;
phit+=1;
hitflag[i] = 2;
}
if(hity[i]<=2)
{
hitflag[i] = 2;
}
if(hitflag[i]==1)
{
putimage(hitx[i],hity[i],bomb[i],XOR_PUT);
}
}
if(ti>=500)
{
gettime(&t);
sprintf(msg," Current Time:%2d:%02d:%02d",t.ti_hour, t.ti_min,t.ti_sec);
setfillstyle(1,12);
bar(xend+3,yend+3,getmaxx()-4,getmaxy()-4);
setcolor(BLACK);
settextstyle(0,0,0);
outtextxy(xend+15,yend+10,msg);
ti = 0;
}
putimage(x,5,ball,XOR_PUT);
putimage(x1,150,ball1,XOR_PUT);
putimage(x2,250,ball2,XOR_PUT);
if(flag==1)
x += speed;
else
x -= speed;
if(x>=xend-23)
{
flag = 0;
}
if(x<=1)
{
flag = 1;
}
if(flag1==1)
x1 += 1+speed;
else
x1 -= 1+speed;
if(x1>=xend-23)
{
flag1 = 0;
}
if(x1<=1)
{
flag1 = 1;
}
if(flag2==1)
x2 += 2+speed;
else
x2 -= 2+speed;
if(x2>=xend-23)
{
flag2 = 0;
}
if(x2<=1)
{
flag2 = 1;
}
putimage(x,5,ball,XOR_PUT);
putimage(x1,150,ball1,XOR_PUT);
putimage(x2,250,ball2,XOR_PUT);
for(i=0;i=gx-5&&rx[i]<=gx+20&&ry[i]>=yend-15&&ry[i]<=yend-5)
{
// count -= 3;
rflag[i] = 2;
life--;
}
}
}
for(i=0;i=gx-5&&yx[i]<=gx+20&&yy[i]>=yend-15&&yy[i]<=yend-5)
{
// count -= 2;
yflag[i] = 2;
life--;
}
}
}
for(i=0;i=gx-5&&px[i]<=gx+20&&py[i]>=yend-15&&py[i]<=yend-5)
{
// count -= 1;
pflag[i] = 2;
life--;
}
}
}
for(i=0;i=yend-5)
{
rflag[i] = 2;
}
for(i=0;i=yend-5)
{
yflag[i] = 2;
}
for(i=0;i=yend-5)
{
pflag[i] = 2;
}
for(i=0;i=30) speed = 2;
if(count>=60) speed = 3;
if(count>=90) speed = 4;
if(count>=120) speed = 5;
delay(12-speed);
ti += 12-speed;
}
}
void end(void)
{
char m[3];
sprintf(m,"%c",3);
clrscr();
cleardevice();
restorecrtmode();
textattr(11);
cprintf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
gotoxy(20,3);
cprintf("THE SCORE BOARD FOR HEART BREAK KID");
printf(" ");
cprintf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
gotoxy(20,7);
textattr(11);
cprintf("TOTAL NUMBER OF FIRE SHOOTED : %d",ats);
gotoxy(20,9);
cprintf("TOTAL NUMBER OF POINTS SCORED : %d",count);
gotoxy(20,11);
textattr(RED);
cprintf("TOTAL NUMBER OF HITS TO RED HEART : %d",rhit);
gotoxy(20,13);
textattr(YELLOW);
cprintf("TOTAL NUMBER OF HITS TO YELLOW HEART : %d",yhit);
gotoxy(20,15);
textattr(12);
cprintf("TOTAL NUMBER OF HITS OT PINK HEART : %d",phit);
printf(" ");
textattr(11);
cprintf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
getch();
/* int gd=DETECT, gm;
initgraph(&gd,&gm,"c:\tc\bgi");
while(!kbhit())
{
setcolor(random(getmaxcolor()));
settextstyle(0,0,1);
outtextxy(random(getmaxx()),random(getmaxy()),m);
setcolor(12);
settextstyle(0,0,2);
outtextxy(100,250,"THANK YOU FOR PLAYING HBK");
}
closegraph();
restorecrtmode();*/
exit(0);
}
void start(void)
{
cleardevice();
settextstyle(10,0,3);
setcolor(12);
outtextxy(150,100,"HEART BREAK KID");
settextstyle(0,0,2);
getch();
cleardevice();
}
void rhits(void)
{
int rflg = 0;
for(j=0;j1)
{
rflag[j] = 1;
rflg = 1;
rx[j] = x-1;
ry[j] = 26;
putimage(rx[j],ry[j],rhrt[j],XOR_PUT);
break;
}
}
if(rflg==0)
{
rflag[rin] = 1;
settextstyle(0,0,1);
setcolor(RED);
sprintf(msg,"%c",che);
outtextxy(x,28,msg);
size2 = imagesize(x-1,28-2,x+8,34);
rhrt[rin] = malloc(size2);
getimage(x-1,28-2,x+8,34,rhrt[rin]);
rx[rin] = x-1;
ry[rin] = 26;
for(j=0;j1)
{
yflag[j] = 1;
yflg = 1;
yx[j] = x1-1;
yy[j] = 171;
putimage(yx[j],yy[j],yhrt[j],XOR_PUT);
break;
}
}
if(yflg==0)
{
yflag[yin] = 1;
settextstyle(0,0,1);
setcolor(YELLOW);
sprintf(msg,"%c",che);
outtextxy(x1,171,msg);
size3 = imagesize(x1-1,171,x1+8,179);
yhrt[yin] = malloc(size3);
getimage(x1-1,171,x1+8,179,yhrt[yin]);
yx[yin] = x1-1;
yy[yin] = 171;
for(j=0;j1)
{
pflag[j] = 1;
pflg = 1;
px[j] = x2-1;
py[j] = 281;
putimage(px[j],py[j],phrt[j],XOR_PUT);
break;
}
}
if(pflg==0)
{
pflag[pin] = 1;
settextstyle(0,0,1);
setcolor(12);
sprintf(msg,"%c",che);
outtextxy(x2,281,msg);
size4 = imagesize(x2-1,281,x2+8,289);
phrt[pin] = malloc(size4);
getimage(x2-1,281,x2+8,289,phrt[pin]);
px[pin] = x2-1;
py[pin] = 281;
for(j=0;j
|