Shoot The Devil game in c
#include
#include
#include "graphics.h"
#include
#include
#include
void exitmessage(void);
void lost(void);
void main()
{
randomize();
int gd=DETECT,gm,no=0,area,maxx,maxy,chance=0;
int ch,x=25,y=25,xdir=1,ydir=1,x1=20,y1,x1dir=0,area1;
void *buff,*cuff;
initgraph(&gd,&gm,"bgi");
setcolor(WHITE);
setfillstyle(SOLID_FILL,RED);
circle(50,50,15); //
floodfill(50,50,WHITE);
arc(25,25,335,360,40);
arc(75,25,180,205,40);
circle(42,45,2);
circle(54,45,2);
setfillstyle(SOLID_FILL,BLACK);
floodfill(42,45,15);
floodfill(54,45,15); //draw devil
setcolor(10);
area=imagesize(25,25,75,75);
buff=malloc(area);
getimage(25,25,75,75,buff);
putimage(25,25,buff,XOR_PUT); //erase devil
maxx=getmaxx();
maxy=getmaxy();
y1=maxy/2;
setcolor(15);
setfillstyle(SOLID_FILL,15);
rectangle(10,y1,12,y1+2); //
floodfill(11,y1+1,15); //draw bullet
area1=imagesize(10,y1,12,y1+2);
cuff=malloc(area1);
getimage(10,y1,12,y1+2,cuff);
putimage(10,y1,cuff,XOR_PUT); //erase bullet
setcolor(14);
rectangle(0,0,maxx,maxy);
setviewport(1,1,maxx-1,maxy-1,1);
settextstyle(1,0,3);
settextjustify(1,1);
delay(4000);
setcolor(15);
while(no<100) no="0;" ch="getch();" ch="=" x1dir="1;" ch="=" x1dir="=" y1="y1-10;" ch="=" x1dir="=" y1="y1+10;" ch="=" x1="x1+10*x1dir;" x="x+(xdir*random(30));" y="y+(ydir*random(20));">=maxx-71) //keep devil within screen
{
xdir*=-1;
x=maxx-71;
}
if(x<=175&&xdir==1) x=175; if(x<=175&&xdir==-1) xdir*=-1; if(y>=maxy-71)
{
ydir*=-1;
y=maxy-71;
}
if(y<=30) { ydir*=-1; y=30; } // if(x1>=maxx-3||x<=1) //failed chance { x1=20; x1dir=0; } if(y1>=maxy-20) //keep gun within screen
y1=maxy-21;
if(y1<=20) y1=21; // if(x1<=x+40&&x1>=x+12&&y1<=y+38&&y1>=y+10) //successful hit
{
moveto(maxx/2,maxy/2);
outtextxy(maxx/2,maxy/2,"...YOU'VE...WON...");
sound(500);
delay(5000);
nosound();
delay(3000);
exit(0);
}
}
while(chance<=10); if(chance=11) lost(); getch(); closegraph(); restorecrtmode(); } void exitmessage() { char cho; outtextxy(getmaxx()/2,getmaxy()/2,"EXIT : Y or N..."); delay(100); flushall(); cho=getch(); if(cho=='y'||cho=='Y') exit(0); else if(cho=='n'||cho=='N') { clearviewport; return; } } void lost() { outtextxy(getmaxx()/2,getmaxy()/2-50,"Your bullets are over"); outtextxy(getmaxx()/2,getmaxy()/2,"The devil destroys the world"); }
No comments:
Post a Comment