DESERTFOX A C++ GAME

Desertfox is my first game that uses mouse interface.The main objective is to shoot down the tanks that are approaching the town using the mouse.It has developed for a school project.Feel free to mail me at davidchristiek@gmail.com

You can download it from here
https://drive.google.com/file/d/0B3kz1y1YuVuJcEZmZUtZQmhwNWc/view?usp=sharing

`#include<iostream.h>

include<conio.h>

include<dos.h>

include<stdlib.h>

include<graphics.h>

include<string.h>

int speed=1,health=50,movementspeed=1;
int change=0;
long score=0;
char scor[10];

void gameover()
{
settextstyle(4,0,6);
setcolor(RED);
outtextxy(200,200,"GAMEOVER");
delay(1000);
cleardevice();
setbkcolor(WHITE);
settextstyle(5,0,3);
outtextxy(50,100,"Thank you for playing");
outtextxy(100,300,strcat("You have scored ",scor));
outtextxy(100,400,"Press space to exit");
char ch='w';
while(ch!=' ')
ch=getch();
}
void credits()
{
setbkcolor(WHITE);
setfillstyle(1,BLUE);
bar(200,200,500,300);
settextstyle(3,0,6);
outtextxy(210,200,"W");
delay(500);
outtextxy(250,200,"O");
delay(500);
outtextxy(280,200,"L");
delay(500);
outtextxy(310,200,"F");
delay(500);
outtextxy(340,200,"P");
delay(500);
outtextxy(370,200,"A");
delay(500);
outtextxy(400,200,"C");
delay(500);
outtextxy(430,200,"K");
delay(1000);
settextstyle(5,0,4);
setcolor(YELLOW);
outtextxy(240,240,"Innovations");
setcolor(RED);
rectangle(200,200,500,300);
getch();
cleardevice();
}
void instructions()
{
setcolor(RED);
outtextxy(200,50,"INSTRUCTIONS");
outtextxy(50,120,"1.Click on the tanks to destroy them");
outtextxy(50,160,"2.Don't let them reach the city");
outtextxy(50,200,"3.Press space to exit");
outtextxy(50,240,"4.Have Fun");
getch();
cleardevice();
}

void main()
{
clrscr();
//GRAPHICS INITILALIZATION
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"c:\tc\BGI");
//MOUSE INITIALIZATION
union REGS in,out;
in.x.ax=0;
int86(51,&in,&out);
in.x.ax=1;
int86(51,&in,&out);
credits();
settextstyle(3,0,3);
//THE TANK
setbkcolor(LIGHTGRAY);
setfillstyle(1,RED);
bar(0,0,20,40);
setcolor(WHITE);
circle(10,20,5);
setfillstyle(6,BLUE);
floodfill(10,20,WHITE);
setcolor(YELLOW);
line(10,20,10,50);
unsigned int size;
struct
{
void *tank;
int x,y;
}tank[2];
size=imagesize(0,0,20,50);
for(int i=0;i<2;i++)
{
tank[i].tank=malloc(size);
getimage(0,0,20,50,tank[i].tank);
}
//The city
void *city;
cleardevice();

setfillstyle(1,BLUE);
bar(400,400,0,450);
setfillstyle(1,YELLOW);
bar(12,442,30,438);
bar(38,442,45,438);
bar(112,442,130,438);
bar(138,442,145,438);
bar(238,442,245,438);
bar(312,442,330,436);
bar(312,442,330,436);
bar(338,442,345,438);
city=malloc(size);
getimage(400,400,0,450,city);
instructions();
cleardevice();
//The Screen
putimage(0,400,city,COPY_PUT);
setfillstyle(1,YELLOW);
setcolor(YELLOW);
setbkcolor(LIGHTGRAY);
line(450,0,450,480);
setfillstyle(9,YELLOW);
floodfill(600,400,YELLOW);
setfillstyle(1,BLUE);
bar(480,90,550,110);
bar(480,205,620,225);
setcolor(RED);
settextstyle(3,0,4);
setfillstyle(1,GREEN);
bar(470,28,630,52);
outtextxy(470,20,"Desert Fox");
settextstyle(3,0,3);
outtextxy(480,85,"SCORE");
bar(460,130,610,180);
outtextxy(480,200,"City HEALTH");
//CREDITS
bar(460,450,640,480);
setcolor(RED);
outtextxy(500,450,"WOLFPACK");
int loopcontroller=0;
//The mechanism
getch();
for(i=0;i<2;i++)
{
tank[i].x=random(400);
tank[i].y=30;

}

char key='o';
for(i=0;i<1000;i++)
{
putpixel(random(450),random(400),i%16);
delay(1);
}
while(key!=' ')
{
if(health==0)
{
gameover();
break;
}
setcolor(WHITE);
settextstyle(3,0,5);
//score
ltoa(score,scor,10);
outtextxy(470,130,scor);
//healthbar
setfillstyle(1,RED);
bar(520,430,540,250+health3);
for(i=0;i<2;i++)
putimage(tank[i].x,tank[i].y,tank[i].tank,OR_PUT);
//Reading mouse
in.x.ax=3;
struct
{
int button,x,y;
}mouse;
int86(51,&in,&out);
mouse.button=out.x.bx;
mouse.x=out.x.cx;
mouse.y=out.x.dx;
//The click checking
if(mouse.button==1)
{
for(i=0;i<2;i++)
{
if(abs(mouse.x-tank[i].x)<30&&abs(mouse.y-tank[i].y<30))//good
{
change=1;
score+=100;
setcolor(GREEN);
outtextxy(470,130,scor);
for(int j=0;j<2;j++)
{
putimage(tank[j].x,tank[j].y,tank[j].tank,XOR_PUT);//Deleting
j+=movementspeed
(random(3)+1);
}
tank[i].x=random(420);
tank[i].y=0;
loopcontroller=1;
}
}
}
if(loopcontroller==1)
{
loopcontroller=0;
continue;
}
for(i=0;i<2;i++)
{
putimage(tank[i].x,tank[i].y,tank[i].tank,XOR_PUT);//DELETING
tank[i].y+=movementspeed*random(3);
if(tank[i].y>300)
{
tank[i].y=0;
tank[i].x=random(400);
change=1;
health-=5;
}
}
if(kbhit())
{
key=getche();
}
setfillstyle(1,GREEN);
if(change==1)
{
bar(520,430,540,250);
change=0;
}
settextstyle(3,0,3);
bar(460,450,640,480);
setcolor(RED);
outtextxy(500,450,"WOLFPACK");
setfillstyle(1,RED);
delay(speed);
}
}`

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories