int play( void )//if the play is entered by user
{
int life = 1, m, x1, x2, x3, s;//assigning values for life, m for selection
//x1,x2,x3 for random values from the randx function
re:
while ( life ) //check the life value to enter the while loop
{
cleardevice();
if ( car.op1 == 0 ) //
{
x1 = randx();//getting the random values
car.op1++;//calling the obstacle in class and incrementing
}
else
{
opp1( x1 );//if not equal to zero print the obstacle
}
if ( car.op2 == 0 )//for obstacle 2
{
x2 = randx();
car.op2++;
}
else if ( car.op2 < 1 ) //for obstacle valueless than 1
{
car.op2++;
}
else
{
opp2( x2 );
}
if ( car.op3 == 0 ) //for obstacle no 3
{
x3 = randx();
car.op3++;
}
else if ( car.op3 < 1 )
{car.op3++;}
else
{
opp3( x3 );
}
setcolor( 10 );
bgmove(); //calling move function for car to appearin sceen
if ( check( x2, car.op2, car.cp ) || check( x1, car.op1, car.cp ) || check( x3, car.op3, car.cp ) )
{ //checking the collision condition from the check function
life--;
if ( life == 0 )
{
over();//calling the over fuction for finishing the game
}
car.op1 = 1; //initializing the obstacle
car.op2 = -16;
car.op3 = -32;
goto re;//using goto to repeat the processes always
}
if ( kbhit() )//check the key stroke
{
m = getch();
switch ( m ) //key stroke decision using switch case
{
case LEFT: left();//for left arrow
break;
case RIGHT: right(); //for right arrow key
break;
case 'q': exit( 0 ); //to exit the game when ever the user want to
}
}
else
{
delay( 100 );
}
}
getch();
return ( 0 );
}
void menu()//for the menu appearance
{
int s = 1, t = 0, a, p = 140;//here s is for keystroke selection in switch case
do//to contiue the program after finish
{ //here a is for the rectangle to move up and down
do //p for rectangle use in menu
{
cleardevice();
setcolor( YELLOW );
settextstyle( 1, 0, 4 );
outtextxy( 230, 30, "MENU" );Mr.007, [28.06.21 23:33]
Mr.007, [28.06.21 22:47]
Wow ur game developer?
Anonymous
PREM SAGAR
Ravi
Manav
TAKINADA
Pavel
?
Hermann
Mickey🕷
mito