Professional Documents
Culture Documents
Tic Tac Toe
Tic Tac Toe
Tic Tac Toe
1. Tanushree.P.Wandkar 2. Latesh.R.S
PROJECT GUIDES: Dr. Poornima B.Ph.D Asst. Professor, CS&E DEPT
4BD09CS114 4BD09CS051
BAPUJI INSTITUTE OF ENGINEERING AND TECHNOLOGYDEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING DAVANGERE-577 004
CERTIFICATE
This is to certify that Tanushree.P.Wandkar and Latesh.R.S bearing USN 4BD09CS114 and 4BD09CS051 respectively has satisfactorily completed the project work entitled TIC TAC TOE & ROCKET SMASH and submitted this report for the academic year 2011-12.
Project Guides
1.____________________ 2._____________________
CERTIFICATE
This is to certify that Tanushree.P.Wandkar bearing USN 4BD09CS114 respectively has satisfactorily completed the project work entitled TIC TAC TOE & ROCKET SMASH and submitted this report for the academic year 2011-12.
Project Guides
----------------------Prof. R. D. Shivanand
Head of Department M.Tech, M.I.S.T.E.I.F.E
1.____________________ 2._____________________
CERTIFICATE
This is to certify that Latesh.R.S bearing USN 4BD09CS051 respectively has satisfactorily completed the project work entitled TIC TAC TOE & ROCKET SMASH and submitted this report for the academic year 2011-12.
Project Guides
----------------------Prof. R. D. Shivanand
Head of Department M.Tech, M.I.S.T.E.F.E.
ACKNOWLEDGEMENTS
Salutations to our beloved and highly esteemed institute, Bapuji Institute of Engineering and Technology for having well qualified staff and labs furnished with necessary equipments. I express our sincere thanks to our guides Dr. Poornima B and Mr. ABDUL RAZAK M.S for giving us constant encouragement, support and valuable guidance throughout the course of the project without whose stable guidance this project would not have been achieved. We express wholehearted gratitude to Prof.SHIVANAND R.D who is our respectable Head of Dept. of Computer Science. We wish to acknowledge his help who made our task easy by providing with his valuable help and encouragement. Our due thanks to Dr. RAMASWAMY, the principal, as we consider ourselves very lucky to have such excellent computing facilities and their inspiration throughout our professional course. We also thank the non-teaching staff of CS Dept. who guided at the time of difficulties. Finally we thank all those who are involved directly and indirectly in completion of our project.
-Tanushree.P.Wandkar -Latesh.R.S
ABSTRACT
Our project which uses OpenGL Technology is a very simple approach towards demonstrating the use of basic features or functions provided in OpenGL. The project is associated with two simple games one of which is called as TIC-TAC-TOE for 2 players, one for Red and other for Blue, who takes turns making the spaces in 3x3 grid. The Red player goes first. The player who succeeds in placing their respective colours in a horizontal, vertical or diagonal rows or columns wins the game. If the players do not succeed in placing their respective colours in a horizontal, vertical or diagonal rows or columns and if there are no further blocks to be filled then the game is considered to be over!!! The other one is called as ROCKET SMASH which is for a single player in which player needs to move his rocket up or down to make itself to survive against the incoming obstacles at different positions. If he collides with the obstacle which is approaching the rocket then the game is over!!!
CONTENTS
Chapter 6: Conclusion
Chapter 7: References
OpenGL (Open Graphics Library) is a standard specification defining a crosslanguage, cro ss-platform API for writing applications that produce 2D and 3D computer graphics. The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. OpenGL is widely used in CAD, virtual reality, scientific visualization, information visualization, flight simulation, and video games. OpenGL specifies a set of "commands" or immediately executed functions. Each command directs a drawing action or causes special effects. A list of these commands can be created for repetitive effects. OpenGL is independent of the windowing characteristics of each operating system, but provides special "glue" routines for each operating system that enable OpenGL to work in that system's windowing environment. OpenGL comes with a large number of built-in capabilities requested. Hidden surface removal, alpha blending (transparency), anti-aliasing , texture
mapping, pixel operations, viewing and modeling transformations, and atmospheric effects (fog, smoke, and haze).through the API.
TIC TAC TOE hardware support. It is designed for use in any graphics applications, from games to modeling to CAD. Many games use OpenGL for their core graphics-rendering engines.
OpenGL Architecture
OpenGL is a collection of several hundred functions providing access to all the features offered by your graphics hardware. Internally, it acts as a state machine--a collection of states that tell OpenGL what to do. Using the API, you can set various aspects of the state machine, including such things as the current color, lighting, blending, and so on. When rendering, everything drawn is affected by the current settings of the state machine. It's important to be aware of what the various states are, and the effect they have, because it's not uncommon to have unexpected results due to having one or more states set incorrectly.
Vertices
Vertex processor
Pixels
Rasterizer
Fragment
processor
1.2
The project is associated with two simple games which is called as Tic-Tac-Toe for 2 players, one for Red and other for Blue, who takes turns making the spaces in 3x3 grid. The Red player goes first. The player who succeeds in placing their respective colours in a horizontal, vertical or diagonal rows or columns wins the game. If the players do not succeed in placing their respective colours in a horizontal, vertical or diagonal rows or columns and if there are no further blocks to be filled then the game is considered to be over!!!. The other one is called as ROCKET SMASH which is for a single player in which player needs to move his rocket up or down to make itself to survive against the incoming obstacles at different positions. If he collides with the obstacle which is approaching the rocket then the game is over!!!
CHAPTER 3: DESIGN
Main Flowchart
Tic-Tac-Toe Flowchart
CHAPTER 4: IMPLEMENTATION
We have used some of the inbuilt functions of the graphics package like
Attributes:
o void glColorf[b I f d ub us ui](TYPE r, TYPE g, TYPE b, TYPE a) Sets the present RGB colours. Valid types are byte (b), int (i), float (f), double (d), unsigned byte (ub), unsigned short (us), and unsigned int (ui). o void glClearcolor(GLclampfr,GLclampfg,GLclampfb,GLclampf a) Sets the present RGBA clear colour used when clearing the colour buffer. Variables of type GLclampf are floating point numbers between 0.0 and 1.0. o void glPointSize(GLfloat size) Sets the point size attribute in pixels.
TIC TAC TOE (GLUT_RGB,GLUT_INDEX)andbuffering (GLUT_SINGLE,GLUT_DOUBLE). o void glutInitWindowSize(intwidth,int height) Specifies the initial height and width of the window in pixels. o void glutWindowPosition(intx,int y) Specifies the initial position of the top-left corner of the window in pixels. o void glViewport(intx,inty,sizeiwidth,sizei height) Specifies a width x height viewport in pixels whose lower-left corner is at (x,y) measured from the origin of the window. o void glutMainLoop() Cause the program to enter an event-processing loop. It should be the last statement in main. o void glutDisplayFunc(void (*func)(void)) Registers the display function func that is executed when the window needs to be redrawn. o void glutPostRedisplay() Requests that the display call-back be executed after the current call-back returns. o void glutSwapBuffers() Swaps the front and back buffers.
Interaction
o intglutCreateMenu(void (*f)(int value) Returns an identifier for a top-level menu and registers the call-back function f that returns an integer value corresponding to the menu entry selected. o void glutAddMenuEntry(char *name,int value) Adds an entry with the string name displayed to the current menu. Values returned to the menu call-back when the entry is selected.
Transformations
o void glMatrixMode(GLenum mode) Specifies which matrix will be affected by subsequent transactions. Mode can be GL_MODEL_VIEW, GL_PROJECTION orGL_TEXTURES. o void glLoadIdentity() Sets the current transformation matrix to an identity matrix.
Viewing
o void gluOrtho2D(GLdoubleleft,GLdoubleright,GLdoublebottom,GLdouble top) Defines a two dimensional viewing rectangle in the plane z=0.
Adding text
o void glutBitmapCharacter(void *font,int char)
void moveobst() { //changes the position of the selectd obstacle and redisplays on the screen. } Moveobst() function moves the selected objects from right end of the screen to left end of the screen. Void night() { //draws a scene of night with moon and three buildings in the background on the screen. } Night() function draws a scene of night with moon and three buildings in the background on the screen. Void movenight() { //moves the scene drawn by the night() function } Movenight() function changes the position of the scene drawn by the night() function and makes it to move in background from right to left.
1. Start Screen
2.START OF TIC-TAC-TOE
4. Red wins
5. Blue wins
6. Game over
9. GAME OVER
CHAPTER 6: CONCLUSION
Our project aimed at achieving the game of TIC-TAC-TOE & ROCKET SMASH where in the TIC TAC TOE originally cross marks circles are used instead we have made use of filling colors into selected blocks We can enhance the same game by changing the grid size from 3x3 to 4x4 or higher sizes so that we can increase the level of difficulty
CHAPTER 7: REFERENCES
Edward Angle,InteractiveComputer Graphics A Top-Down Approach With OpenGL, Pearson Education, 5th Edition, 2008.