ROAD OF THE DEAD in C++
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
copyright @ programming seekers
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include<iostream.h>
#include<conio.h>
#include<time.h>
#include<graphics.h>
#include<stdlib.h>
#include<string.h>
#include<dos.h>
#include<stdio.h>
main()
{ restart: clrscr(); textbackground(15);textcolor(4);
cout<<"\n\t\t\t\tROAD OF THE DEAD\nCreated by usman siddique\n\n\n"
<<" #-YOUR CAR\n\n *-HURDLES\n\n"
<<" COMMANDS:\n 1.j- move left\n\n 2.l- move right\n\n"
<<" DIFFICULTY\n A.LEARNER\n B.EXPERT\n\n PRESS E To GO BACK TO MENU"
<<"\n\n ENTER YOUR CHOICE:";
char ch= getche();
if((ch!='a')&&(ch!='A')&&(ch!='b')&&(ch!='B')&&(ch!='e')&&(ch!='E'))
goto restart;
if((ch=='e')||(ch=='E'))
exit(0);
char A[49][11]; int h=45; int p=13; int i,j,k,speed,score=0;
for(i=3; i>0; i--)
{ delay(1000); clrscr();
cout<<"\n\n\n\n\n\n\n\t\t\t\t\t\t"<< i; delay(1000); clrscr();
}
for (int t=1; t<3; t++)
{
for(int v=1;v<=49;v++)
{
if((ch=='a')||(ch=='A')) // learner path
{
for(i=0;i<49; i++)
for(j=0; j<11; j++)
{ A[i][j]=' ';
if((j==0)||(j==10))
A[i][j]='*';
}
for(i=3;i<49; i=i+13)
{ A[i][2]='*';
A[i][5]='*';
A[i][8]='*';
}
for(i=6;i<49; i=i+10)
{ A[i][4]='*';
A[i][6]='*';
A[i][9]='*';
}
for(i=8;i<49; i=i+13)
{ A[i][1]='*';
A[i][3]='*';
A[i][7]='*';
}
for(i=0;i<49;i++)
{
for(j=0; j<11; j++)
{
k=j+40; gotoxy(k,(i+1));
cout<<A[i][j];
}
cout<<'\n';
}
speed=300;
speed=speed-(2*v);
}
else
{ //expert path
for(i=0;i<49; i++)
for(j=0; j<11; j++)
{ A[i][j]=' ';
if((j==0)||(j==10))
A[i][j]='*';
}
for(i=3;i<49; i=i+7)
{ A[i][2]='*';
A[i][5]='*';
A[i][8]='*';
}
for(i=6;i<49; i=i+8)
{ A[i][4]='*';
A[i][6]='*';
A[i][9]='*';
}
for(i=8;i<49; i=i+7)
{ A[i][1]='*';
A[i][3]='*';
A[i][7]='*';
}
for(i=0;i<49;i++)
{
for(j=0; j<11; j++)
{
k=j+40; gotoxy(k,(i+1));
cout<<A[i][j];
}
cout<<'\n';
}
speed=250;
speed=speed-(2*v);
}
if (kbhit())
{ char cmnd=getch() ;
if(cmnd=='l')
h=h+1 ;
if(cmnd=='j')
h=h-1 ;
}
gotoxy(h,v);
score=score+(3*v);
cout<<"#";
char c=A[v-1][h-40] ;
if(c=='*')
goto gameover;
// speed=speed-(2*v);
delay(speed);
}
}
gameover: clrscr();
cout<<"\n\n\n\n\t\t\t\tGAME OVER"
<<"\n\n\t\t\t\tYOUR SCORE IS "
<<score;
getch();
goto restart;
}
Post a Comment