#include<iostream.h>
#include<alloc.h>
#include<dos.h>
#include<conio.h>
#include<stdlib.h>;
#include<graphics.h>
void front_page();
void second_page();
void final_page();
long o=0,g=0,a=20;
float v;
char w;
void main()
{ int gde=DETECT,gme;
initgraph(&gde,&gme,"c:\\tc");
mit: //label
front_page();
w=getch();
switch(w)
{ case '1':v=1.2; break;
case '2':v=2.0; break;
case '3':v=5; break;
default: goto mit;
}
cleardevice();
int c=0;
char *h;
second_page();
int maxx,maxy,area,x=580,ch,xdirn=1,ydirn=1;
float y=25;
void *buff;
setcolor(WHITE);
setfillstyle(SOLID_FILL,RED );
circle(605,50,25);
floodfill(605,50,WHITE);
area=imagesize(580,25,630,75);
buff=malloc(area);
getimage(580,25,630,75,buff);
maxx=getmaxx();
maxy=getmaxy();
while(1)
{ putimage(x,y,buff,XOR_PUT);
//delay(0);
y=y+(ydirn*v);
putimage(x,y,buff,XOR_PUT);
if(y>maxy-50||y<20)
{ c=0;
sound(130);
delay(5);
nosound();
ydirn*=-1;
}
int marea,m=98,n=235,ch,mdirn=1,ndirn=1,mn;
int maxm,maxn,narea,buffn;
void *buffe;
setcolor(DARKGRAY);
setfillstyle(SOLID_FILL,DARKGRAY );
rectangle(98,235,105,239);
floodfill(101,237,DARKGRAY);
marea=imagesize(98,235,105,239);
buffe=malloc(marea);
getimage(98,235,105,239,buffe);
maxm=getmaxx();
maxn=getmaxy();
gotoxy(2,10);
int in;
cout<<"BULLETS REMAINING = ";
for(in=0;in<=a-1;in++)
{ cout<<"!";
}
if(kbhit())
{ mn=getch();
char *bul;
if(a==0)
break;
if((mn==115||mn==83) &&c==0)
{ a=a-1;
cout<<0;
sound(9999);
delay(10);
c++;
nosound();
while(m<=maxm)
{ putimage(m,n,buffe,XOR_PUT);
m=m+(mdirn*2);
delay(0);
putimage(m,n,buffe,XOR_PUT);
gotoxy(11,3);
cout<<g;
if(m==maxm-51 && (y<=235 && y+25>=205))
{ g=g+10;
o=g;
sound(2200);
delay(900);
putimage(700,25,buff,XOR_PUT);
nosound();
}
}
}
else
{ if(mn==27)
break;
}
}
}
cleardevice();
final_page();
getch();
closegraph();
}
void front_page()
{ setbkcolor(GREEN);
setcolor(WHITE);
setfillstyle(SOLID_FILL,RED );
circle(505,190,50);
floodfill(505,190,WHITE);
setcolor(BROWN);
line(0,235,35,235);
line(0,235,0,258);
line(35,240,35,235);
line(0,258,35,240);
setfillstyle(1,BROWN);
floodfill(2,240,BROWN);
setcolor(DARKGRAY);
line(35,235,102,235);
line(35,240,35,235);
line(35,240,102,240);
line(102,235,102,240);
setfillstyle(1,DARKGRAY);
floodfill(99,236,DARKGRAY);
arc(35,220,250,310,25);
line(35,242,38,243);
settextstyle(1,0,1);
setcolor(BLUE);
outtextxy(200,300,"MADE BY :- MOHIT VASHISHT");
outtextxy(200,317,"E_MAIL :- mohitvashisht88@yahoo.com");
settextstyle(4,0,5);
outtextxy(200,50,"SHOOTING");
outtextxy(250,120,"GAME");
gotoxy(20,12);
cout<<" 1 : EASY";
gotoxy(20,13);
cout<<" 2 : MEDIUM";
gotoxy(20,14);
cout<<" 3 : TOUGH";
gotoxy(10,16);
cout<<"ENTER THE LEVEL = ";
}
void second_page()
{ setcolor(BROWN);
setbkcolor(YELLOW);
line(0,235,35,235);
line(0,235,0,258);
line(35,240,35,235);
line(0,258,35,240);
setfillstyle(1,BROWN);
floodfill(2,240,BROWN);
setcolor(DARKGRAY);
line(35,235,102,235);
line(35,240,35,235);
line(35,240,102,240);
line(102,235,102,240);
setfillstyle(1,DARKGRAY);
floodfill(99,236,DARKGRAY);
arc(35,220,250,310,25);
line(35,242,38,243);
outtextxy(10,35,"SCORE");
outtextxy(10,50,"FIRE");
outtextxy(50,50,"S");
outtextxy(10,65,"EXIT");
outtextxy(50,65,"esc");
}
void final_page()
{ setcolor(BROWN);
setbkcolor(RED);
for(int x=1;x<=4;x++)
{
clrscr();
setbkcolor(RED);
delay(100);
gotoxy(31,12);
cout<<"YOUR SCORE = "<<o;
sound(2200);
delay(750);
nosound();
}
gotoxy(28,16);
cout<<"PRESS ANY KEY TO EXIT";
}
- Upinder Singh Dhami
- Bangalore, Karnataka, India
- Extending one hand to help someone has more value rather than joining two hands for prayer
project of shooting game
Tuesday, September 1, 2009Posted by Upinder Singh Dhami at Tuesday, September 01, 2009 4 comments
Labels: games
project of three dimensional calculator working with mouse
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<graphics.h>
#include<dos.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<process.h>
int aaa=247,bbb=167,l2,status,rep=0,mul=0;
char ch,st2[50],st1[2];
double f1=0,f2=0,d1=0,d2=0,d3=0;
void buttan1(int,int,int,int);
void buttan(int,int,int,int);
void text();
void screen(char);
void scremt();
void main()
{ int d,mm,e,a,b,c,k;
d=DETECT;
initgraph(&d,&mm,"c:/tc");
e=graphresult();
if(e!=0)
{
cout<<"Graphics not inialised";
getch();
return;
}
setbkcolor(BLUE);
setcolor(7);
rectangle(aaa-10,bbb-50,aaa+153,bbb+150);
setfillstyle(1,7);
floodfill(aaa,bbb,7);
setcolor(15);
int f[]={aaa-15,bbb-55,aaa+158,bbb-55,aaa+153,bbb-50,aaa-10,bbb-50,aaa-10,bbb+150,aaa-15,bbb+155,aaa-15,bbb-55};
drawpoly(7,f);
setfillstyle(1,15);
floodfill(aaa-12,bbb-42,15);
setcolor(8);
int h[]={aaa+158,bbb-55,aaa+158,bbb+155,aaa-15,bbb+155,aaa-10,bbb+150,aaa+153,bbb+150,aaa+153,bbb-50,aaa+158,bbb-55};
drawpoly(7,h);
setfillstyle(1,8);
floodfill(aaa+156,bbb-40,8);
for(int ii=1;ii<17;ii++)
{
buttan(aaa,bbb,15,8);
aaa+=39;
if(ii%4==0)
{ bbb+=39;
aaa=247;
}
}
buttan1(236,75,15,8);
buttan1(350,75,15,8);
aaa=247;
bbb=167;
text();
scremt();
REGS n,m;
n.x.ax=0;
int86(0x33,&n,&m);
k=m.x.ax;
if(k==0)
return;
int aa,bb,t1,t2;
while(1)
{ n.x.ax=1;
int86(0x33,&n,&m);
n.x.ax=3;
int86(0x33,&n,&m);
a=m.x.cx;
b=m.x.dx;
c=m.x.bx;
// FOR EXIT XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
if(c==1 && a>350 && a<400 && b>75 && b<100)
{ buttan1(350,75,8,15);
delay(200);
cleardevice();
cleardevice();
setcolor(RED);
outtextxy(50,50,"MADE BY:");
outtextxy(50,80,"UPINDER SINGH DHAMI");
outtextxy(50,110,"B.TECH (FIFTH SEM)");
outtextxy(50,140,"ELECTRONICS AND COMM ENGG");
outtextxy(50,170,"GURU NANAK DEV UNIVERSITY (AMRITSAR)");
outtextxy(50,200,"DATE: 17\\07\\2008");
delay(7000);
return;
}
// FOR RECET XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
if(c==1 && a>236 && a<286 && b>75 && b<100)
{ rep=0;
mul=0;
buttan1(236,75,8,15);
delay(200);
buttan1(236,75,15,8);
strcpy(st2,"");
screen(' ');
scremt();
}
// FOR FIRST ROW XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// FOR 7
if(c==1 && a>aaa && a<(aaa+25) && b>bbb && b<(bbb+25))
{
buttan(aaa,bbb,8,15);
delay(200);
buttan(aaa,bbb,15,8);
screen('7');
mul=0;
continue;
}
// FOR 8
if(c==1 && a>(aaa+39) && a<(aaa+64) && b>bbb&&b<(bbb+25))
{
buttan((aaa+39),bbb,8,15);
delay(200);
buttan((aaa+39),bbb,15,8);
screen('8');
mul=0;
continue;
}
// FOR 9
if(c==1 && a>(aaa+78) && a<(aaa+103) && b>bbb&&b<(bbb+25))
{
buttan((aaa+78),bbb,8,15);
delay(200);
buttan((aaa+78),bbb,15,8);
screen('9');
mul=0;
continue;
}
// FOR +
if(c==1 && a>(aaa+117) && a<(aaa+142) && b>bbb&&b<(bbb+25))
{ rep++;
mul++;
if(mul==2)
{ rep--;
mul--;
}
if(rep==2)
goto label;
status=2;
buttan((aaa+117),bbb,8,15);
delay(200);
buttan((aaa+117),bbb,15,8);
d1=f1;
strcpy(st2,"");
scremt();
continue;
}
//FOR SECOND ROW XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// FOR 4
if(c==1 && a>aaa && a<(aaa+25) && b>(bbb+39) && b<(bbb+64))
{
buttan(aaa,bbb+39,8,15);
delay(200);
buttan(aaa,bbb+39,15,8);
screen('4');
mul=0;
continue;
}
//FOR 5
if(c==1 && a>(aaa+39) && a<(aaa+64) && b>(bbb+39) && b<(bbb+64))
{
buttan(aaa+39,bbb+39,8,15);
delay(200);
buttan(aaa+39,bbb+39,15,8);
screen('5');
mul=0;
continue;
}
//FOR 6
if(c==1 && a>(aaa+78) && a<(aaa+103) && b>(bbb+39) && b<(bbb+64))
{
buttan(aaa+78,bbb+39,8,15);
delay(200);
buttan(aaa+78,bbb+39,15,8);
screen('6');
mul=0;
continue;
}
//FOR -
if(c==1 && a>(aaa+117) && a<(aaa+142) && b>(bbb+39) && b<(bbb+64))
{ rep++;
mul++;
if(mul==2)
{ rep--;
mul--;
}
if(rep==2)
goto label;
status=3;
buttan(aaa+117,bbb+39,8,15);
delay(200);
buttan(aaa+117,bbb+39,15,8);
d1=f1;
strcpy(st2,"");
scremt();
continue;
}
// FOR THIRD ROW XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// FOR 1
if(c==1 && a>aaa && a<(aaa+25) && b>(bbb+78) && b<(bbb+103))
{
buttan(aaa,bbb+78,8,15);
delay(200);
buttan(aaa,bbb+78,15,8);
screen('1');
mul=0;
continue;
}
//FOR 2
if(c==1 && a>(aaa+39) && a<(aaa+64) && b>(bbb+78) && b<(bbb+103))
{
buttan(aaa+39,bbb+78,8,15);
delay(200);
buttan(aaa+39,bbb+78,15,8);
screen('2');
mul=0;
continue;
}
//FOR 3
if(c==1 && a>(aaa+78) && a<(aaa+103) && b>(bbb+78) && b<(bbb+103))
{
buttan(aaa+78,bbb+78,8,15);
delay(200);
buttan(aaa+78,bbb+78,15,8);
screen('3');
mul=0;
continue;
}
//FOR *
if(c==1 && a>(aaa+117) && a<(aaa+142) && b>(bbb+78) && b<(bbb+103))
{ rep++;
mul++;
if(mul==2)
{ rep--;
mul--;
}
if(rep==2)
goto label;
status=1;
buttan(aaa+117,bbb+78,8,15);
delay(200);
buttan(aaa+117,bbb+78,15,8);
d1=f1;
strcpy(st2,"");
scremt();
continue;
}
// FOR FORTH ROW XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// FOR 0
if(c==1 && a>aaa && a<(aaa+25) && b>(bbb+117) && b<(bbb+142))
{
buttan(aaa,bbb+117,8,15);
delay(200);
buttan(aaa,bbb+117,15,8);
screen('0');
mul=0;
continue;
}
// FOR .
if(c==1 && a>(aaa+39) && a<(aaa+64) && b>(bbb+117) && b<(bbb+142))
{
buttan(aaa+39,bbb+117,8,15);
delay(200);
buttan(aaa+39,bbb+117,15,8);
screen('.');
mul=0;
continue;
}
// FOR =
if(c==1 && a>(aaa+78) && a<(aaa+103) && b>(bbb+117) && b<(bbb+142))
{
buttan(aaa+78,bbb+117,8,15);
delay(200);
buttan(aaa+78,bbb+117,15,8);
label:
if(status==1)
{ d2=f1;
d3=d1*d2;
}
if(status==2)
{ d2=f1;
d3=d1+d2;
}
if(status==3)
{ d2=f1;
d3=d1-d2;
}
if(status==4)
{ d2=f1;
d3=d1/d2;
}
char temp[50];
int sig = 10;
gcvt(d3, sig, temp);
strcpy(st2,"");
strcpy(st2,temp);
scremt();
screen(' ');
rep=0;
mul=0;
continue;
}
// FOR %
if(c==1 && a>(aaa+117) && a<(aaa+142) && b>(bbb+117) && b<(bbb+142))
{ rep++;
mul++;
if(mul==2)
{ rep--;
mul--;
}
if(rep==2)
goto label;
status=4;
buttan(aaa+117,bbb+117,8,15);
delay(200);
buttan(aaa+117,bbb+117,15,8);
d1=f1;
strcpy(st2,"");
scremt();
continue;
}
}
getch();
closegraph();
}
void buttan(int x, int y,int ltcolor,int rtcolor)
{
setcolor(7);
rectangle(x,y,x+25,y+25);
setfillstyle(1,7);
floodfill(x+2,y+2,7);
setcolor(ltcolor);
int a[]={ x-2,y-2,x+27,y-2,x+25,y,x,y,x,y+25,x-2,y+27,x-2,y-2};
drawpoly(7,a);
setfillstyle(1,ltcolor);
floodfill(x-1,y+5,ltcolor);
setcolor(rtcolor);
int b[]={x+27,y-2,x+27,y+27,x-2,y+27,x,y+25,x+25,y+25,x+25,y,x+27,y-2 };
drawpoly(7,b);
setfillstyle(1,rtcolor);
floodfill(x+26,y+5,rtcolor);
}
void text()
{ setcolor(4);
outtextxy(aaa+9,bbb+10,"7");
outtextxy(aaa+48,bbb+10,"8");
outtextxy(aaa+87,bbb+10,"9");
outtextxy(aaa+126,bbb+10,"+");
outtextxy(aaa+9,bbb+49,"4");
outtextxy(aaa+48,bbb+49,"5");
outtextxy(aaa+87,bbb+49,"6");
outtextxy(aaa+126,bbb+49,"-");
outtextxy(aaa+9,bbb+88,"1");
outtextxy(aaa+48,bbb+88,"2");
outtextxy(aaa+87,bbb+88,"3");
outtextxy(aaa+126,bbb+88,"*");
outtextxy(aaa+9,bbb+127,"0");
outtextxy(aaa+48,bbb+124,".");
outtextxy(aaa+87,bbb+127,"=");
outtextxy(aaa+126,bbb+127,"%");
outtextxy(243,85,"RESET");
outtextxy(361,85,"EXIT");
settextstyle(7,HORIZ_DIR,1);
outtextxy(aaa+50,bbb+250,"MADE BY: UPINDER SINGH DHAMI");
settextstyle(0,0,1);
}
void screen(char ch)
{ setcolor(15);
rectangle(aaa-5,bbb-40,aaa+148,bbb-10);
setfillstyle(1,15);
floodfill(aaa,bbb-20,15);
// outtextxy(aaa+140,bbb,"0.");
scremt();
if(ch!='a')
{
setcolor(1);
st1[0]=ch;
st1[1]='\0';
strcat(st2,st1);
}
l2=strlen(st2);
if(l2>19)
{ scremt();
setcolor(BLUE);
outtextxy(250,136," data overflow");
return;
}
f1 = atof(st2);
outtextxy(395-(l2*8),136,st2);
}
void scremt()
{ setcolor(14);
rectangle(aaa-5,bbb-40,aaa+148,bbb-10);
setfillstyle(1,14);
floodfill(aaa,bbb-20,14);
}
void buttan1(int x, int y,int ltcolor,int rtcolor)
{
setcolor(7);
rectangle(x,y,x+50,y+25);
setfillstyle(1,7);
floodfill(x+2,y+2,7);
setcolor(ltcolor);
int a[]={ x-4,y-4,x+54,y-4,x+50,y,x,y,x,y+25,x-4,y+29,x-4,y-4};
drawpoly(7,a);
setfillstyle(1,ltcolor);
floodfill(x-3,y-3,ltcolor);
setcolor(rtcolor);
int b[]={x+54,y-4,x+54,y+29,x-4,y+29,x,y+25,x+50,y+25,x+50,y,x+54,y-4};
drawpoly(7,b);
setfillstyle(1,rtcolor);
floodfill(x+52,y+10,rtcolor);
setcolor(1);
}
Posted by Upinder Singh Dhami at Tuesday, September 01, 2009 0 comments