Dora Catch Game Computer Graphics Project in OpenGL Source Code – 18CSL67

Dora Catch Game Computer Graphics Project in OpenGL Source Code – 18CSL67

Here you can download the source code of Dora Catch Game Computer Graphics Project in OpenGL for academic mini-project.

Project Description:

The mini-project, ”Dora Catch”, allows the player to play with the objects. The player is allotted with a basket and with the help of control keys i.e “a |A” for left movement and “d |D” for the right movement, he/she has to move the basket so as to catch the “Dora’s” i.e the falling objects. The player can also make use of the mouse as a controller. Upon catching a Dora, the player gains a point and this is displayed on the scoreboard. The game has three phases, i.e Level 1, Level 2, and Level 3.

* Level 1:

At this level, there are three Dora’s which fall at normal speed (Initial speed).

Another Dora called as “Buzzy Dora” fall. Upon catching this Buzzy Dora, the player gains reward points.

Upon gaining a total of ten points, the player will switch on to level 2.

If the player misses 10 Dora’s, then the game ends.

*Level 2:

In this level, the complexity of the game increases making the game difficult for the player.

The speed of the Dora’s is comparatively faster in this level.

*Level 3:

This is the final level of the game. In this level, the game becomes even more complex.

The speed of the Dora’s is faster compared to level 2.

Module Description

1. MAIN FUNCTION – In OpenGL, GLUT runs as a console application starting at main. The glutInit() initializes the window system and to enable the single buffered mode glutInitDisplayMode(GLUT_SINGLE) is used.

The size and position of the window is defined using glutInitWindowSize(width,height), glutInitWindowPosition(posX,posY) respectively.

The window is created using glutCreateWindow(“DoraCatch”) and the name of the created window is given in quotes. The following functions are registered to be used in the program :

1. glutReshapeFunc()

2. glutDisplayFunc(display)

3. glutKeyboardFunc()

4. glutTimerFunc()

And finally, glutMainLoop() is used to enter the event processing loop and calls the functions which are registered in the body of the main function.

2. RESHAPE FUNCTION – This Function is called back when the windows are re-sized. It first computes aspect ratio of the new window then it computes aspect ratio of the new window and finally it sets the aspect ratio of the clipping area to match the viewport. In this function, the edges are defined and the boundary is set so that the objects can interact within the boundaries.

3. MYDISPLAY FUNCTION – In mydisplay(), four functions have been called. The following is the list of functions :

frontscreen(), instr(), display() and missdisp()

i. frontscreen() – The front screen function displays the information about the project i.e. title of the project, group name, made by, and guided by. It uses a drawstring function to display the information. It is also the beginning phase of the program. Here the player has an option: to start the game press ‘Enter’ which is followed by the instr() window. If the user presses ‘S’ then display() window is called thus allowing the player to interact with the game.

READ  Flying Ball Computer Graphics Project in OpenGL Source Code – 18CSL67

ii. instr() – The instr function displays the instructions of the game which is very helpful to a beginner. This window is displayed when the user presses ‘S’ at the front screen window. It uses a drawstring function to display the string of characters.

iii. display() – The display function registers call back handler for window re-paint. In this function two functions are being called basket() and disp(). The glClear() API is used to clear the window background and  glClearColor() API specifies the RGB and alpha values to clear the color buffers. These API’s are called before calling the functions basket() and disp() and finally glFlush() forces the buffered OpenGL commands to execute.

4. BASKET FUNCTION -This function is used to display the basket. We have used GL_QUADS to draw the basket. The moveright() and moveleft() are  used to move the basket to different x positions. The variable xb is  used to compute the location of next refresh where as yb is kept constant.

5. DISP FUNCTION – In this function star1, star2, star3, scredisp, and missd functions are called. Along with this, we use the following functions:

glPushMatrix(): It pushes the current matrix stack down by one, duplicating the current matrix. That is,  after glPushMatrix call, the matrix on top of the stack is identical to the one below it.

glPopMatrix(): It pops the current matrix stack, replacing the current matrix with the one below it on the stack.

i. STAR1(), STAR2(), and STAR3() – These functions are used to display the stars. We have used a GL_QUADS function to draw the stars. Initially, the color of the stars is set to a specific color using glColor3f() function. s1,s2, and s3 variables are used to decrement the y coordinate of the star1,star2, and star3 respectively which results in the downward movement of the stars.xs1, xs2 and xs3 represent the x coordinates of the star1,star2 and star3 respectively.

* level2() – The level2 function is invoked when the user scores 10 points in level1 with the count of miss less than 10. It is a link between Level 1 and Level 2 where the program asks the user to press ‘l’ to proceed to the next level.

* level3() – The level3 function is invoked when the user scores a total of 20 points in level1 and level2 with the count of miss less than 10. It is a link between Level2 and Level3 where the program asks the user to press  ‘g’ to proceed to the next level.

READ  17CS36 - Discrete Mathematics and its Applications Notes

ii. SCREDISP – This function is used to the display the score .The glRasterPos() API is used to set the x and y axis for the text. The glutBitmapCharacter() API is used to render the character in the named bitmap font. With every click on the ball the score will be implemented. We have used drawstring() to display the string “SCORE” on top left corner.

iii. MISSD – This function is used to count the missed catches. If the count of the miss is equal to 10, the game ends.

6. TIMER FUNCTION – The glutTimerFunc() registers a timer callback to be triggered in a specified number of milliseconds. In this glutPostRedisplay is used which posts a paint request to activate display().

7. KEYBOARD FUNCTION – The glutKeyboardFunc() API is used to set the keyboard callback to the current window. Here we have created three cases using a switch statement, the first case is quit which is invoked by pressing the “q|Q” button. The second case is “d|D” which invokes the moveright() function, resulting in the movement of the basket towards the right. And the last case is ‘a’|’A’ which invokes the moveleft() function, resulting in the movement of the basket towards the left.

Flowchart of Dora Catch Game

Dora Catch Game Computer Graphics Project in OpenGL Source Code – 18CSL67

Source Code of Dora Catch Game Computer Graphics Project

#include<GL/glut.h>
#include<stdio.h>
#include<math.h>
#include<stdbool.h>
#define PI 3.14159265f
GLfloat w=500,h=500;
void disp();
int x1,by, count=0,miss=0,xxxradius=100;
int s1=0,s2=0,s3=0,l=5;
float e,x,y,angle=0.0;
int flag=0,flag1=0,flag2=0,flag3=0,speed=2, flagl2=0,level=1;

static void key(unsigned char key, int x, int y);
void mymouse(int btn,int state,int x3,int y3);
void missdisp();
void scoredisp();
void star1();
void star2();
void star3();
void basket();
void level2();
void level3();
int n=60, m=0;
GLfloat xb=200, yb=20, xs1=230,xs2=330,xs3=160;
//GLfloat xb=200, yb=20, xs1=260,xs2=360;
void display();
void drawstring(float x,float y,float z,char *string)
{
 char *c;
 glRasterPos3f(x,y,z);
 for(c=string;*c!='\0';c++)
 {
  glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,*c);
 }
}
void frontscreen(void)
{
glClearColor(0.4, 0.0,1.0,1.0);	
int xxxradius=200;
	
	{
	 glClear(GL_COLOR_BUFFER_BIT);
	 glColor3f(1.0,1.0,0.0);
	glBegin(GL_TRIANGLE_FAN);
	for(angle=0; angle<360; angle+=1)
	{
    		y =250+(cos(angle*PI/180)*xxxradius);
    		x =250+(sin(angle*PI/180)*xxxradius);
    		glVertex2f(x,y);
	}
	glEnd();
	
 
  glPointSize(10.0);
 glColor3f(0.0,0.0,0.0);
 
 glBegin(GL_POINTS);
 		glVertex2f(220,270);
 		glVertex2f(280,270);
 
 glEnd();
 glLineWidth(10.0);
 glBegin(GL_LINE_STRIP);
 		glVertex2f(210,220);
 		glVertex2f(235,200);
 		glVertex2f(250,195);
 	glVertex2f(265,200);
 //	glVertex2f(250,200);
 		glVertex2f(290,220);
 glEnd();
 
}

                                              //GLfloat xb=200, yb=20, xs1=230,xs2=330,xs3=160;
	//glColor3ub( rand()%255, rand()%255, rand()%255 );
	

	
	glColor3f(1.0,0.0,0.0);
	 drawstring(170,450,0.0,"TRAILBLAZERS");
	glColor3f(0.9,0.0,1.0);
	 drawstring(195,415,0.0,"PRESENTS");
	glColor3f( 0.0,0.0,1.0 );  
	 drawstring(168,380,0.0,"~DORACATCH~"); 
	 glColor3f( 1.0,0.0,0.0 );  
	 drawstring(30,250,0.0,"BY:");
	 glColor3f( 0.9,0.0,1.0 );  
	 drawstring(30,210,0.0,"Name");
	drawstring(30,185,0.0,"Name");
	glColor3f( 1.0,0.0,0.0 ); 
	 drawstring(350,250,0.0,"GUIDE : ");
	  glColor3f( 0.9,0.0,1.0 );
	drawstring(320,210,0.0,"Prof. ");
	glColor3f( 0.0,0.0,1.0 ); 
	 // drawstring(140,120,0.0,"Press i for Instructions"); 
	glColor3ub( rand()%250, rand()%250, rand()%200 );  
	 drawstring(140,80,0.0,"Press ENTER to Begin ");
	 //glColor3f( 0.0,1.0,0.4 ); 
  
	glFlush();
}
void instr()
{
	glClear(GL_COLOR_BUFFER_BIT);
	glClearColor(0.0,0.0,0.0,1.0);
	glColor3f( 0.0,0.0,0.9 );
	drawstring(180,450,0.0,"Instructions ");
	drawstring(20,400,0.0,"1.The player has to catch the falling DORAs ");
	drawstring(20,373,0.0,"into the basket to gain the Score. ");
	 drawstring(20,342,0.0,"2.a/A to move the basket to the left and d/D to ");
	 drawstring(20,315,0.0,"move the basket to the right. ");
	 drawstring(20,284,0.0,"3.Each DORA will increament the Score by +1. ");
	 drawstring(20,253,0.0,"4.Upon catching the fast moving BUZY DORA ");
	 drawstring(20,226,0.0,"the player will gain Bonus Score of +3. ");
	 drawstring(20,195,0.0,"5.A Score of 10 will lead the player to the next   ");
	 drawstring(20,168,0.0,"level increasing the complexity for the player. ");
	 drawstring(20,137,0.0,"6.A Miss of 10 will end the game. ");
	 drawstring(20,106,0.0,"7.To Quit the game at any stage press q/Q ");
	 
	// drawstring(200,50,0.0,"GOOD LUCK! ");
	 
	glColor3ub( rand()%250, rand()%250, rand()%200 );  
 	drawstring(120,60,0.0,"PRESS 's' TO START");
	
	glFlush();
}

void mydisplay(void)
{   if(flag==0&&flag1==0 &&flag2==0)
    	frontscreen ();

    if(flag1==1 && flag==0 &&flag2==0)//&&flag==0)
        instr();
        
   
   if(flag==1 && flag1==0 &&flag2==0)
   	display();

   if(miss>=10 && flag==1 && flag1==1)
   missdisp();
   //scoredisp();

   /*if(count==10 && flag==1)
   
    {
   //display();
   	level2();
   
    }
   */
}


void reshape (int w, int h)
{
	glViewport(0,0,w,h);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	if(w>h)
			gluOrtho2D((GLfloat)w/(GLfloat)h*(0),(GLfloat)w/(GLfloat)h*(500),0,500);
else
			gluOrtho2D(0,500,(GLfloat)h/(GLfloat)w*(0),(GLfloat)h/(GLfloat)w*500);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}
void mytimer(int v)
{
	glutPostRedisplay();
	glutTimerFunc(25, mytimer, v);
}

void moveright(void)
{
	if(xb+50 < 500)
   		xb=xb+7;
	basket();
	//glTranslatef(5, 0.0, 0.0);		 
}
void moveleft(void)
{
	if(xb>0)
	xb=xb-7;
	basket();
	//glTranslatef(-5, 0.0, 0.0);
    		 
}
void level2()
{
	flag=1;
	flag1=1;
	//s1=0;
	//s2=0;
	//s3=0;
	glClear(GL_COLOR_BUFFER_BIT);

	glRasterPos2f(200,250);
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'L');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'E');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'V');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'E');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'L');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,' ');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'2');
	glRasterPos2f(200,100);
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'P');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'R');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'E');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'S');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'S');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,' ');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'L');

	glFlush();

}
void level3()
{
	flag=1;
	flag1=1;
	flagl2=1;
	//s1=0;
	//s2=0;
	//s3=0;
	glClear(GL_COLOR_BUFFER_BIT);

	glRasterPos2f(200,250);
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'L');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'E');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'V');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'E');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'L');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,' ');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'3');
	glRasterPos2f(200,100);
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'P');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'R');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'E');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'S');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'S');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,' ');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'g');

	glFlush();

}

int main(int argc,char **argv)
{
        glutInit(&argc,argv);
        glutInitWindowSize(500,500);
	glutInitWindowPosition(300,200);
			
	glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
	glutCreateWindow("DoraCatch");
	glutDisplayFunc(mydisplay);	
	
        glutReshapeFunc(reshape);
        glutKeyboardFunc(key);
       	glutMouseFunc(mymouse);
        glutTimerFunc(100, mytimer, n);
        
        glutMainLoop();

}
static void key(unsigned char key1, int x, int y)
{
	switch(key1)
	{
		case 'Q': 
		case 'q':
			exit(0);  
			break;
		case 'D':
		case 'd':
			  
			moveright();
			break;
		case 'A':
		case 'a':
			  
			moveleft();
		        break;
	 case 13:  flag1=1;
	 		//	if(flag1==0)
	 		//	flag=1;
	 		//	flag1=0;
              		break;
	case 's': if(flag1==1)
		  {
	           	flag=1;
			flag1=0;
		}
	          
	break;   
     
    	case 'l': if(flag1==1) // level 2
		  {
	           	flag=1;
			flag1=0;
			speed=speed+1;
		  }
 	            break;   
	
	case 'g':if(flagl2==1) // level 3
	{
		flag=1;
		flagl2=0;
		flag1=0;
		speed=speed+2;
	}
	break;
	
}
}
void mymouse(int btn,int state,int x3,int y3)
{
	if(btn==GLUT_LEFT_BUTTON && state==GLUT_DOWN)
	moveleft();
	if(btn==GLUT_RIGHT_BUTTON && state==GLUT_DOWN)
	moveright();
}
void color1()
{
	
	if(count<10)
	glColor3f(1.0,0.0,0.8);
	else if(count<20)
	glColor3f(0.8,0.0,1.0);
	else if(count>20)
	glColor3ub( rand()%255, rand()%255, rand()%255 );  
}
void color2()
{
	
	if(count<10)
	glColor3f(0.0,1.0,0.0);
	else if(count<20)
	glColor3f(0.0,0.8,0.8);
	else if(count>20)
	glColor3ub( rand()%255, rand()%255, rand()%255 );  
}

void color3()
{
	
	if(count<10)
	glColor3f(1.0,0.0,0.0);
	else if(count<20)
	glColor3f(1.0,1.0,0.5);
	else if(count>20)
	glColor3f(1.0,0.0,0.0);
	//glColor3ub( rand()%260, rand()%250, rand()%255 );  
}




void star1()
{    
	if(s1==-500)
	s1=0;                                              //GLfloat xb=200, yb=20, xs1=230,xs2=330,xs3=160;
	//glColor3ub( rand()%255, rand()%255, rand()%255 );
//	glColor3f(1.0, 0.0,0.8);
	glBegin(GL_QUADS);
	color1();
		glVertex2f(xs1,s1+500);
		glVertex2f(xs1-10,s1+470);
		glVertex2f(xs1,s1+440);
		glVertex2f(xs1+10,s1+470);
	glEnd();
	if(s1>-500 & m == 0)// & count <10)
	{
		s1=s1-speed;
		printf("s1-->%d\t",s1);
	}
    
   	if(s1==-396 & xb+10<=xs1 & xs1<=xb+50)
	{
		m=1;	
		count=count+1;
		s1=-500;
		s1=s1+speed;
		if(count>=10 & level==1)
		{
			
			level2();	
			level=2;
		
		}
	 if(count>=20 & level==2)
		{
			level3();	
			level=3;
		}
		xs1=xs1-(rand()%50);
		m=0;		
		star1();
	}
	
	
	else if(s1==-396 & xb-10<=xs1<=xb+50 )
	{
		miss=miss+1;
		s1=-500;
		if(miss==10)
			missdisp();
	}

	
	//return count;
}
	
	

void star2()
{    
	if(s2==-600)
	s2=0;
	//glColor3ub( rand()%255, rand()%255, rand()%255 );
        // glColor3f(0.0,1.0,0.0);
        color2();
	 glBegin(GL_QUADS);
		glVertex2f(xs2,s2+600);
		glVertex2f(xs2-10,s2+570);
		glVertex2f(xs2,s2+540);
		glVertex2f(xs2+10,s2+570);
	glEnd();


	if(s2>-600 & m==0)// &count<10) 
	{
		s2=s2-speed;
		printf("s2-->%d\t",s2);
	}

	if(s2 ==-480 & xb+10<=xs2 & xs2<=xb+50)
	{
		m=1;	
		count=count+1;
		s2=-600;
		s2=s2+speed;
		if(count>=10 & level==1)
		{
			level2();	
			level=2;
		}
		 if(count>=20 & level==2)
		{
			level3();	
			level=3;
		}
		xs2=xs2-(rand()%40);
		m=0;		
		star2();
	
	}
	else if(s2 ==-480 & xb-10<=xs2<=xb+50)
	{
		miss=miss+1;
		s2=-600;
		if(miss==10)
			missdisp();
	}
}

void star3()
{	
	if(s3==-500)               //GLfloat xb=200, yb=20, xs1=230,xs2=330,xs3=160;
		s3=0;
//	glColor3f(1.0,0.0,0.0);
color3();
	glBegin(GL_LINE_LOOP);
		glVertex2f(xs3,s3+500);
		glVertex2f(xs3+10,s3+480);
		glVertex2f(xs3+20,s3+500);
		glVertex2f(xs3+15,s3+500);
                glVertex2f(xs3+10,s3+490);
                glVertex2f(xs3+5,s3+500);
                glVertex2f(xs3,s3+500);

	glEnd();

	if(s3>-500 & m==0)// & count<10)
	{
		s3=s3-speed;
		printf("s3-->%d\t",s3);
		
	}
	if(s3==-420 & xb+2<=xs3 & xs3<=xb+50)
	{
		m=1;	
		count=count+3;
		s3=-500;
		s3=s3+speed;
		if(count>=10 & level==1)
		{
			level2();	
			level=2;
		}
		 if(count>=20 & level==2)
		{
			level3();	
			level=3;
		}
		xs3=xs3+(rand()%30);
		m=0;		
		star3();
	
	}
	else if(s3==-420 & xb-2<=xs3<=xb+50 )
	{
		miss=miss+1;
		s3=-500;
		if(miss==10)
			missdisp();
	}
}




void basket()
{
	//glColor3ub( rand()%255, 0.0, rand()%255 );
	glColor3f(0.9,0.9,0.9);
	 glBegin(GL_QUADS);                  // GLfloat xb=200, yb=20, xs1=260,xs2=360,xs3=160;
	 	
		glVertex2f(xb,yb);
		glVertex2f(xb+50,yb);
		glVertex2f(xb+50,yb+40);
		glVertex2f(xb,yb+40);
	glEnd();
        glColor3f(1.0,0.0,0.0);
        glBegin(GL_LINES);
               glVertex2f(xb,yb);
               glVertex2f(xb+50,yb+40);
        glEnd();
        glColor3f(1.0,0.0,0.0);
        glBegin(GL_LINES);
               glVertex2f(xb+50,yb);
               glVertex2f(xb,yb+40);
        glEnd();
        glBegin(GL_LINE_STRIP);
               glVertex2f(xb+25,yb);
               glVertex2f(xb+50,yb+20);
               glVertex2f(xb+25,yb+40);
               glVertex2f(xb,yb+20);
               glVertex2f(xb+25,yb);
        glEnd();
        glLineWidth(3.0);
        glBegin(GL_LINES);
               glVertex2f(xb,yb+60);
               glVertex2f(xb,yb);
               glVertex2f(xb+50,yb);
               glVertex2f(xb+50,yb+60);
        glEnd();
}

void display()
{
	glClear(GL_COLOR_BUFFER_BIT);
	glClearColor(0.0,0.0,0.0,1.0);
	//glColor3f(1.0,0.0,0.0);	
   	 basket();
         //scoredisp();
	disp();	
	//missdisp();
	glFlush();
		  
}
void disp()
{
	
	glColor3f(1.0,0.0,0.0);		   
 	glPushMatrix();
 	 glLoadIdentity();
	star1();
	 glPopMatrix();
	 glutSwapBuffers();
	  glPushMatrix();
 	 glLoadIdentity();
	star2();
	 glPopMatrix();
	 glutSwapBuffers();
	glPushMatrix();
 	 glLoadIdentity();
	star3();
	 glPopMatrix();
	 glutSwapBuffers();
	glPushMatrix();
 	 
	glPushMatrix();
 	 glLoadIdentity();
	 scoredisp();
	 glPopMatrix();
	 glPushMatrix();
 	 glLoadIdentity();
	 missd();
	 glPopMatrix();
}
void missd()
{
int p,m=0,n=0;
    p=miss;	
	//glLoadIdentity();
	glColor3f(0.0,0.0,1.0);
	glRasterPos2f(10,400);
	glutBitmapCharacter(GLUT_BITMAP_8_BY_13,'M');
	glutBitmapCharacter(GLUT_BITMAP_8_BY_13,'I');
	glutBitmapCharacter(GLUT_BITMAP_8_BY_13,'S');
	glutBitmapCharacter(GLUT_BITMAP_8_BY_13,'S');
	glutBitmapCharacter(GLUT_BITMAP_8_BY_13,':');
//	glutBitmapCharacter(GLUT_BITMAP_8_BY_13,miss+48);
		while(p > 9)
        {
            n = p % 10;
            glRasterPos2f (62,400);
             glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,48+n);         
           p /= 10;
           glRasterPos2f(55,400);    
       }     
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,48+p); 	
	
	//glFlush();
	 
}
void scoredisp()
{
	int z,j=0,k=0;
	z=count;

	//glLoadIdentity();
	glColor3f(0.0,0.0,1.0);
	glRasterPos2f(10,450);
	glutBitmapCharacter(GLUT_BITMAP_8_BY_13,'S');
	glutBitmapCharacter(GLUT_BITMAP_8_BY_13,'C');
	glutBitmapCharacter(GLUT_BITMAP_8_BY_13,'O');
	glutBitmapCharacter(GLUT_BITMAP_8_BY_13,'R');
	glutBitmapCharacter(GLUT_BITMAP_8_BY_13,'E');
	glutBitmapCharacter(GLUT_BITMAP_8_BY_13,':');

	//glutBitmapCharacter(GLUT_BITMAP_8_BY_13,count+48);
		while(z > 9)
        {
            k = z % 10;
            glRasterPos2f (62,450);
             glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,48+k);         
           z /= 10;
           glRasterPos2f(55,450);    
       }     
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,48+z); 	
}


void missdisp()
{
	flag=1;
	flag1=1;
	flag2=1;
	glClear(GL_COLOR_BUFFER_BIT);
	scoredisp();
	missd();
	glRasterPos2f(160,250);
	glColor3f(1.0,1.0,0.0);
	glBegin(GL_TRIANGLE_FAN);
	for(angle=0; angle<360; angle+=1)
	{
    		y =250+(cos(angle*PI/180)*xxxradius);
    		x =250+(sin(angle*PI/180)*xxxradius);
    		glVertex2f(x,y);
	}
 glEnd();
 
 glPointSize(20.0);
 glColor3f(0.0,0.0,0.0);
 
 glBegin(GL_POINTS);
 		glVertex2f(210,270);
 		glVertex2f(290,270);
 
 glEnd();
 glLineWidth(20.0);
 glBegin(GL_LINE_STRIP);
 		glVertex2f(200,180);
 	//	glVertex2f(250,200);
 	glVertex2f(225,200);
 	glVertex2f(275,200);
 		glVertex2f(300,180);
 glEnd();
 glLineWidth(5.0);
 glColor3f(1.0,1.0,0.9);
 glBegin(GL_LINES);
 	glVertex2f(210,250);
 	glVertex2f(210,240);
 	glVertex2f(290,250);
 	glVertex2f(290,240);
 	glVertex2f(210,220);
 	glVertex2f(210,210);
 	glVertex2f(290,220);
 	glVertex2f(290,210);
 	//glVertex2f(215,240);
 glEnd();	
 glColor3f(0.0,0.0,1.0);
 glRasterPos2f(170,50);
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'G');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'A');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'M');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'E');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,' ');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'O');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'V');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'E');
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'R');
	glFlush();

}

Screenshots of Dora Catch Game

Instruction - Dora Catch Game

Instruction – Dora Catch Game

Level 1 - Dora Catch Game

Level 1 – Dora Catch Game

Level 2 - Dora Catch Game

Level 2 – Dora Catch Game

Level 3 - Dora Catch Game

Level 3 – Dora Catch Game

READ  Glass Cracking Computer Graphics Project in OpenGL Source Code – 18CSL67

The project report will be given on request. Download Source Code of Dora Catch Game Computer Graphics Project in OpenGL – 18CSL67. Subscribe to our YouTube channel for more videos and like the Facebook page for regular updates.

Leave a Comment

Your email address will not be published. Required fields are marked *