Hello ;
In the game I wrote now . I give the user the choice of the number of lives he want to begin the game with (1,2, or 3(
void showlife1 (void)
{
glPushMatrix(); //save matrix
glEnable(GL_LIGHTING);
glTranslatef(-66.0f,70.0f,15.0f);
glColor3f(0.0f, 0.0f, 1.0f);
glutSolidSphere( 3.5,15,15);
glPopMatrix(); //restore matrix
}
void showlife2 (void)
{
glPushMatrix(); //save matrix
glEnable(GL_LIGHTING);
glTranslatef(-60.0f,70.0f,15.0f);
glColor3f(0.0f, 0.0f, 1.0f);
glutSolidSphere( 3.5,10,10);
glPopMatrix(); //restore matrix
}
void showlife3 (void)
{
glPushMatrix(); //save matrix
glEnable(GL_LIGHTING);
glTranslatef(-54.0f,70.0f,15.0f);
glColor3f(0.0f, 0.0f, 1.0f);
glutSolidSphere( 3.5,10,10);
glPopMatrix(); //restore matrix
}
if (nLifes == 2) {showlife1();}
if (nLifes == 3) {showlife1(); showlife2 (); }
if (nLifes == 4) {showlife1(); showlife2 ();showlife3 ();}
If he chooses two lives for example … Two spheres will appear in the top of the game to remind the user about how many lives he chose…
The number of lives must reduced whenever the ball missed the user bar ( i.e, the number of collision increases )
nBall1Collision = nBall1Collision +1 ;
if ( nBall1Collision = 1) {dontshowlife1(); }
else if ( nBall1Collision = 2) {dontshowlife2();}
else if ( nBall1Collision = 3) {dontshowlife3();}
// dontshowlife# is the same of showlife# but the color is similar to the background
if( nBall1Collision == nLifes )
{
show_Ball1 = false;
nBall1Collision = 0;
}
Unfortunately, I have no result … I don’t know where is if I follow the right way to code “Appearance and Disppearance of number of lives” … or where is my mistake here …
Any help will be appreciated …