EGG CATCHER game MINI PROJECT(naveenBTLIT)

Views:
 
     
 

Presentation Description

vtu 6th sem project

Comments

Presentation Transcript

A PRESENTATION ON “EGG CATCHER” game MINI PROJECT:

A PRESENTATION ON “EGG CATCHER” game MINI PROJECT From: NAVEEn N & MADHU G M Project Guide: Mr. Jeyadevan S

“EGG CATCHER MINI GAME:

“EGG CATCHER MINI GAME Egg 1 Egg 3 Egg 2 Bonus point

PowerPoint Presentation:

hen( ) This is the function that will draw the hen. Here we draw the face by drawing a polygon of white color,crown by drawing a rectangle of red color,eyes by drawing points of black color,beak by drawing a triangle of red color,body by drawing a polygon of white color,right and left wings by drawing triangles of red color and the legs by drawing triangles of red color. egg1( ) This function demonstrates the falling of white colored egg from postion 1. egg2( ) This function demonstrates the falling of yellow colored egg from postion 2 egg3( ) This function demonstrates the falling of white colored egg from postion 3. net( int x,int y): This function draws a net by drawing the mesh and a point to catch the falling egg.

PowerPoint Presentation:

After the game is started by calling the key_to_start function which matches with the character given by the user to start the game by calling the display function. In the display function we draw the background and call the functions Drawhen ( )-to draw hen Egg ( )-to make the egg fall Netmove ( )-to move the net to the specified position.

PowerPoint Presentation:

Flow Diagram MainFunc Call menu func : select the level using this function Score display: Display the score By identifieng the eggs keyboardFunc : IF key matches DisplayFunc : calls back the functions to display the start screen

PowerPoint Presentation:

x -x y -y void drawhen ( int x,int y) { //head glColor4f(1.0,1.0,1.0,1.0); glBegin (GL_POLYGON); glVertex2f(x-15,y); glVertex2f(x+15,y); glVertex2f(x+30,y+15); glVertex2f(x+15,y+30); glVertex2f(x-15,y+30); glVertex2f(x-30,y+15); glEnd (); //body glBegin (GL_POLYGON); glVertex2f(x-15,y); glVertex2f(x+15,y); glVertex2f(x+60,y-30); glVertex2f(x+30,y-60); glVertex2f(x-30,y-60); glVertex2f(x-60,y-30); //rightwing glColor4f(1.0,0,0,.6); glBegin (GL_POLYGON); glVertex2f(x+60,y-30); glVertex2f(x-10,y-40); glVertex2f(x+75,y-40); //left wing glColor4f(1,0,0,.6); glBegin (GL_POLYGON); glVertex2f(x-60,y-30); glVertex2f(x+10,y-50); glVertex2f(x-75,y-40); //legs glPointSize (7.0); glBegin (GL_POINTS); glVertex2f(x-20,y-65); glVertex2f(x+20,y-65); glEnd (); (x+15,y+30) (x+30,y+15) (x+15,y) (x-15,y) (x-30,y+15) (x-15,y+30) (x+10,y+15) ( x,y ) (x-10,y+15) (x+60,y-30) (x+30,y-60) (x-30,y-60) (x-60,y-30) (x,y+30) (x+10,y-50) (x-10,y-40) (x+75,y-40) (x-75,y-40)

PowerPoint Presentation:

Function for listing the Menu: void callmenu () { submenu= glutCreateMenu (submenu1); glutAddMenuEntry ("press the arrow keys - left, right, down",10); glutAddMenuEntry ("to control or to egg fall press f1",12); submenu3= glutCreateMenu (submenu2); glutAddMenuEntry ("level1",1); glutAddMenuEntry ("level2",2); menu1= glutCreateMenu (menu); glutAddMenuEntry ("start",1); glutAddSubMenu (" insruction",submenu ); glutAddSubMenu ("level",submenu3); glutAddMenuEntry ("exit",4); glutAttachMenu (GLUT_RIGHT_BUTTON);//with the right click of mouse display the menu } menu_select : Displays the menu on right mouse click by using of attach menu and also allows the user to exit. LEVELS: Selects the level for increase the spead of the eggs. After scoring of 48 eggs it will automaticall swap. CONTROL of EGG:this function will control the flow of eggs by pressing f1 in the keyboard.

PowerPoint Presentation:

Reshape function : void myReshape ( int w, int h) { glViewport (0, 0, w, h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluPerspective (40.0, ( GLfloat )w / ( GLfloat )h, 1.0, 20.0); glMatrixMode (GL_MODELVIEW); } glViewport glViewport specifies the affine transformation of x and y from normalized device coordinates to window coordinates glLoadIdentity glLoadIdentity replaces the current matrix with the identity matrix. It is semantically equivalent to calling glLoadMatrix with the identity matrix glMatrixMode sets the current matrix mode.

PowerPoint Presentation:

Init function : void myinit () { glClearColor (1.0,.0,0.0,1.0); glEnable (GL_BLEND); //enable the blending glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //set the blend function glMatrixMode (GL_PROJECTION); glLoadIdentity (); glOrtho (0.0,600.0,0.0,600.0,-600,600);//describes a transformation that produces a parallel projection. } glEnable glEnable and glDisable enable and disable various capabilities GL_BLEND Before you can use an OpenGL library functions, it must be positioned using the glBlend command and enabled using glEnable ( GL_BLEND ) where 'n' is 0 through 7. Gl_DEPTH_TEST : used for hidden surface removal while viewing an object in primitive environment glMatrixMode It will give the input matrix To the stack for begin the projection.

PowerPoint Presentation:

Different operations using the keys If the UP arrow is pressed game will be begin. If the ‘Right key‘ is pressed the net will be moved to the right side in the window. If the ‘DOWN key’ is pressed the net will be move to middle side of the window. If the ‘Left key’ is pressed the net will be move to left side of the window. void keys( int key,int x,int y) { if(key==GLUT_KEY_UP) glutDisplayFunc (display2); glutPostRedisplay (); if(key==GLUT_KEY_RIGHT) { pos=2;//right end } if(key==GLUT_KEY_LEFT) { pos=1;//left end } if(key==GLUT_KEY_DOWN) { pos=0;//centre } if(key==GLUT_KEY_F1) { t1=0; t2=0; t3=0; } }

PowerPoint Presentation:

Display Func : void display() { glPushMatrix (); if(pos==1) { if(t1==-200) //if first egg is caught { t1=-200; score[0]+=1; if(score[0]==58) { score[1]++;//if level 1 is croseed increase the level 2 score score[0]=48; //level 1 score finalised } // sc1(); scale1=0; } } if(t1<-300) {t1=0; scale1=1;} if(level==0) { glTranslatef (0,t1-=2,0);} if(level==1) { glTranslatef (0,t1-=2,0); } glScalef (scale1,scale1,scale1); egg1(); glPopMatrix (); glPushMatrix (); The display function is used to display and it include the following functions glClear - clear buffers to preset values . sets the bitplane area of the window to values previously selected by glClearColor , glClearDepth glPushMatrix - pushes the current matrix stack down by one, duplicating the current matrix. That is, after a glPushMatrix call, the matrix on top of the stack is identical to the one below it. glPopMatrix - pops the current matrix stack, replacing the current matrix with the one below it on the stack.Initially , each of the stacks contains one matrix, an identity matrix. It is an error to push a full matrix stack, or to pop a matrix stack that contains only a single matrix. In either case, the error flag is set and no other change is made to GL state.

PowerPoint Presentation:

glOrtho - describes a matrix that produces a parallel projection. (left, bottom, -near) and (right, top, -near) specify the points on the near clipping plane that are mapped to the lower left and upper right corners of the window, respectively, assuming that the eye is located at (0, 0, 0). -far specifies the location of the far clipping plane. Both near and far can be either positive or negative. glDepthMask - specifies whether the depth buffer is enabled for writing. If flag is GL_FALSE, depth buffer writing is disabled . glutSwapBuffers - glutSwapBuffers swaps the buffers of the current window if double buffered. Performs a buffer swap on the layer in use for the current window. Specifically, glutSwapBuffers promotes the contents of the back buffer of the layer in use of the current window to become the contents of the front buffer. The contents of the back buffer then become undefined. The update typically takes place during the vertical retrace of the monitor, rather than immediately after glutSwapBuffers is called. glutPostRedisplay - glutPostRedisplay marks the normal plane of current window as needing to be redisplayed egg3(); glPopMatrix (); scoredisp (); netmove (); callmenu (); glFlush (); glutPostRedisplay (); glutSwapBuffers (); }

PowerPoint Presentation:

Main Func : void main( int argc,char ** argv ) { glutInit (& argc,argv ); glutInitDisplayMode (GLUT_DOUBLE|GLUT_RGB); glutInitWindowSize (700,600); glutInitWindowPosition (0,0); glutCreateWindow ("EGG CATCHER GAME"); glutDisplayFunc ( start_screen ); glutSpecialFunc (keys); glutKeyboardFunc ( key_to_start ); myinit (); glutMainLoop (); } The main function calls all the other function in the program A window is created for displaying the result We can position the window by using glutInit WindowPosition We can set the window to any desired size by using the function glutInitWindowSize We add different menus in the result window to have operations on our result. We use the function glutAddMenuEntry glutInitDisplayMode The initial display mode is used when creating top-level windows, subwindows , and overlays to determine the OpenGL display mode for the to-be-created window or overlay.

PowerPoint Presentation:

At beginning the display function will display the welcome screen After pressing the key E it will Enter to the start screen.

PowerPoint Presentation:

In the start stage of the game the nest is in middle of the screen.

PowerPoint Presentation:

The level of the game is selected by right click of the mouse.

PowerPoint Presentation:

After catching the egg the score board will display the count.

PowerPoint Presentation:

An attempt has been made to develop an OpenGL package which meets necessary requirements of the user successfully. Since it is user friendly, it enables the user to interact efficiently and easily. The development of the mini project has given us a good exposure to OpenGL by which we have learnt some of the technique which help in development of animated pictures, gaming. Hence it is helpful for us even to take up this field as our career too and develop some other features in OpenGL and provide as a token of contribution to the graphics world. CONCLUSION

PowerPoint Presentation:

THANK YOU

authorStream Live Help