You are on page 1of 27

TIC TAC TOE

VISVESVARAYA TECHNOLOGICAL UNIVERSITY


BELGAUM-590 018

MINI PROJECT REPORT ON

TIC TAC TOE & ROCKET SMASH


PROJECT ASSOCIATES

1. Tanushree.P.Wandkar 2. Latesh.R.S
PROJECT GUIDES: Dr. Poornima B.Ph.D Asst. Professor, CS&E DEPT

4BD09CS114 4BD09CS051

Mr.ABDULRAZAK M.S.B.E (M. Tech) Lecturer, CS&E DEPT

2011-12 Bapuji Educational Association (Regd.)

BIET (CS&E Dept.)

TIC TAC TOE

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

-----------------------Dr. Poornima B.Ph.D Asst. Professor, CS&E DEPT

-------------------Mr. ABDUL RAZAK M.S.B.E (M. Tech) Lecturer, CS&E DEPT

----------------------Prof. R. D. ShivanandM.Tech, M.I.S.T.E.I.F.E


Head of Department

Signature of the Examiner: Date :______________ Place:______________


BIET (CS&E Dept.)

1.____________________ 2._____________________

TIC TAC TOE

VISVESVARAYA TECHNOLOGICAL UNIVERSITY


BELGAUM-590 018

BAPUJI INTITUTE OF ENGINEERING AND TECHNOLOGY DAVANGERE-577 004

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

-----------------------Dr. Poornima B.Ph.D Asst. Professor, CS&E DEPT

-------------------Mr. ABDUL RAZAK M.S.B.E (M. Tech) Lecturer, CS&E DEPT

----------------------Prof. R. D. Shivanand
Head of Department M.Tech, M.I.S.T.E.I.F.E

Signature of the Examiner:

Date :______________ Place:______________

1.____________________ 2._____________________

BIET (CS&E Dept.)

TIC TAC TOE

VISVESVARAYA TECHNOLOGICAL UNIVERSITY


BELGAUM-590 010

BAPUJI INTITUTE OF ENGINEERING AND TECHNOLOGY DAVANGERE-577 004

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

-----------------------Dr. Poornima B.Ph.D Asst. Professor, CS&E DEPT

-------------------Mr.ABDULRAZAK M.S.B.E (M. Tech) Lecturer, CS&E DEPT

----------------------Prof. R. D. Shivanand
Head of Department M.Tech, M.I.S.T.E.F.E.

Signature of the Examiners: Date :______________ Place:______________ 1.____________________ 2._____________________

BIET (CS&E Dept.)

TIC TAC TOE

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

BIET (CS&E Dept.)

TIC TAC TOE

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!!!

BIET (CS&E Dept.)

TIC TAC TOE

CONTENTS

Chapter 1: Introduction 1.1 OpenGL 1.2 Project Problem statement

Chapter 2: Hardware and software requirements

Chapter 3: Design of Project

Chapter 4: Implementation Details

Chapter 5: Result and Snapshots

Chapter 6: Conclusion

Chapter 7: References

BIET (CS&E Dept.)

TIC TAC TOE

CHAPTER 1:INTRODUCTION 1.1 OpenGL:

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.

Open GL Graphics System:


OpenGL (for Open Graphics Library) is a software interface to graphics hardware. The interface consists of a set of several hundred procedures and functions that allow a programmer to specify the objects and operations involved in producing high-quality graphical images, specifically color images of three-dimensional objects. OpenGL provides the programmer with an interface to graphics hardware. It is a powerful, low-level rendering and modeling software library, available on all major platforms, with wide

BIET (CS&E Dept.)

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

Clipper and primitive assembler

Pixels

Rasterizer

Fragment

processor

1.2

Project Problem Statement

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!!!

BIET (CS&E Dept.)

TIC TAC TOE

CHAPTER 2: SOFTWARE AND HARDWARE REQUIREMENTS


SOFTWARE REQUIREMENTS: Operating System Memory Language Tool Compiler Libraries HARDWARE REQUIREMENTS: Processor RAM Hard disk space Input device Output device : Intel 386 onwords Compatiable Hardware : 256MB RAM (minimum) : 5 gigabytes or more. : Mouse & keyboard : Monitor : Any Windows Platform (Except 98). : 8MB of RAM : C++ : Visual Studio C++ 6.0 : Supporting glut32.h and 32 bit color resolution

BIET (CS&E Dept.)

TIC TAC TOE

CHAPTER 3: DESIGN
Main Flowchart

BIET (CS&E Dept.)

TIC TAC TOE

Tic-Tac-Toe Flowchart

BIET (CS&E Dept.)

TIC TAC TOE

Rocket smash flowchart

BIET (CS&E Dept.)

TIC TAC TOE

CHAPTER 4: IMPLEMENTATION
We have used some of the inbuilt functions of the graphics package like

Specifying simple geometry:


o Void glBegin(glEnum mode) Initiates a new primitive of type mode and starts the collection of vertices. Values of mode include GL_POINTS,GL_LINES,GL_POLYGON. o void glEnd() Terminates a list of vertices.

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.

Working with the window system


o void glFlush() Forces any buffered OpenGL command to execute . o void glutInit(intargc,char **argv) Initializes GLUT. The arguments from main are passed in and can be used by the application. o intglutCreateWindow(char *title) Creates a window on the display. The string title can be used to label the window. The return value provides a reference to the window that can be used when there are multiple windows. o void glutInitDisplayMode(unsigned int mode) Requests a display with the properties in mode. The value of mode is determined by the logical OR of options including the colour model

BIET (CS&E Dept.)

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.

BIET (CS&E Dept.)

TIC TAC TOE

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)

Additional Functions used in our Project:


Void draw () { //draw the 3x3 grid on the screen } Draw () function draws the green colored 3x3 grid on the screen. This function is called from display as soon as the keyd is pressed. Void drawpolygon () { //draws the polygon in red or blue color } Drawpolygon() function draws a square at the valid location specified by the mouse pointer in the grid when the key r or b is pressed. Void rocket() { /draws a rocket on the screen/ } Rocket() function draws a rocket looking object on the screen which can be controlled by keys a and s for its movement. Void obstacle() { //defines two obstacles at two different positions on the screen. } obstacle function predefines two obstacles which randomly selects one of those two and moves from right to left . BIET (CS&E Dept.)

TIC TAC TOE

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.

BIET (CS&E Dept.)

TIC TAC TOE

CHAPTER 5 : RESULTS AND SNAPSHOTS

1. Start Screen

BIET (CS&E Dept.)

TIC TAC TOE

2.START OF TIC-TAC-TOE

BIET (CS&E Dept.)

TIC TAC TOE

3. 3x3 grid (empty)

BIET (CS&E Dept.)

TIC TAC TOE

4. Red wins

BIET (CS&E Dept.)

TIC TAC TOE

5. Blue wins

BIET (CS&E Dept.)

TIC TAC TOE

6. Game over

BIET (CS&E Dept.)

TIC TAC TOE

7. START OF ROCKET SMASH

BIET (CS&E Dept.)

TIC TAC TOE

8. GAMING UNDER PROGRESS

BIET (CS&E Dept.)

TIC TAC TOE

9. GAME OVER

BIET (CS&E Dept.)

TIC TAC TOE

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.

WEBSOURCES www.google.com www.OpenGL simple examples. www.wikipedia.com www.swiftlesstutorials.com

BIET (CS&E Dept.)