Professional Documents
Culture Documents
CHAPTER 1
INTRODUCTION
1.1 Computer Graphics
Graphics provides one of the most natural means of communicating with a computer,
since our highly developed 2D and 3D pattern recognition abilities allow us to perceive and
process pictorial data rapidly and efficiently. Interactive computer graphics is the most
important means of producing pictures since the invention of photography and television. It
has the added advantage that, with the computer, we can make pictures not only of concrete
real word objects but also of abstract, synthetic objects, such as mathematical surfaces and of
data that have no inherent geometry, such as survey results.
1.2 OpenGL
Display Lists
All data, whether it describes geometry or pixels, can be saved in a display list for
current or later use. When a display list is executed, the retained data is sent from the display
list just as if it were sent by the application in immediate mode.
Evaluators: All geometric primitives are eventually described by vertices. Parametric curves
and surfaces may be initially described by control points and polynomial functions called
basis functions.
Per Vertex Operations: For vertex data, next is the "per-vertex operations" stage, which
converts the vertices into primitives. Some vertex data are transformed by 4 x 4 floating-
point matrices. Spatial coordinates are projected from a position in the 3D world to a position
on your screen.
Pixel Operation: While geometric data takes one path through the OpenGL rendering
pipeline, pixel data takes a different route. Pixels from an array in system memory are first
unpacked from one of a variety of formats into the proper number of components. Next the
data is scaled, biased, and processed by a pixel map. The results are clamped and then either
written into texture memory or sent to the rasterization step.
Rasterization: Rasterization is the conversion of both geometric and pixel data into
fragments. Each fragment square corresponds to a pixel in the framebuffer. Color and depth
values are assigned for each fragment square.
Fragment Operations: Before values are actually stored into the framebuffer, a series of
operations are performed that may alter or even throw out fragments. All these operations
can be enabled or disabled.
The aim of this project is to develop a 3D Game which supports basic operations
which include Movement, Artificial Intelligence, collision Detection and also transformation
operations like translation, rotation, scaling etc on objects. The package must also have a
user friendly interface.
1.4 Scope
CHAPTER 2
REQUIREMENTS
This graphics package has been designed for UBUNTU Platform and uses ECLIPSE
integrated environment.
CHAPTER 3
DESIGN
CHAPTER 4
IMPLEMENTATION
Pacman_Move ( )
{
Both the x and y updated coordinates are calculate
using the speed of the pacman and trigonometric functions.
}
Pacman_Draw()
{
Here, the pacman is drawn using the glutSolidSphere() function
And the eyes of the pacman is rendered using a combination of
Random coloring and glutSolidSphere() function.
}
Monster_init()
{
Here , all the variable values are initialized at the beginning of the Game.
}
Monster_Move ()
{
Both the x and y updated coordinates are calculate
using the speed of the Monster and trigonometric functions.
}
Monster_Updation()
{
Here, the state of the monster is updated.
The edibility condition is checked and the flag is set.
If the monster is eaten, then the jail timer starts &
The monster is sent to jail.
}
Monster_Vulnerable()
{
Checks the edible condition for the monsters.
}
Monster_Chase()
{
Here , depending on the edible condition for the Monsters ,
they are set to chase pacman or escape from it.
This is done by using the x-y coordinates of the pacman.
The random movement of the monsters is also handled
}
Monster_draw()
{
Here, the pacman is drawn using the glutSolidSphere () function.
The color of the monsters is changed depending on the edible Condition.
Board_draw()
{
Here , the board is rendered.
Its done in 2 steps to avoid complication in depth.
Depending on the x-y coordinates , the board is rendered
Using different walls.
The pebbles are also rendered here .
Using the random f( ) , the color of the pebbles is changed
To give it a flicker effect.
}
Render_scene()
{
This is the default display function.
Here , the collision detection for pacman , the conditions for
Normal & super pills consumption, with monster movements
Are covered. Options are provided for game control.
}
Create_list()
{
This function is used to create the basic primitive walls using
Display lists. Based on the position, the appropriate list are called.
}
Syntax:
glPushMatrix( );
glPopMatrix( );
Description:
Pushes the current transformation matrix onto the matrix stack. The glPush Matrix()
function saves the current coordinate system to the stack and glPopMatrix() restores the prior
coordinate system.
2.Solid Sphere
Syntax:
Parameters:
Description:
Renders a sphere centered at the modeling coordinates origin of the specified radius.
The sphere is subdivided around the Z axis into slices and along the Z axis into stacks.
3.getAsyncKeyState Function:
Syntax:
Parameters:
Specifies one of 256 possible key codes. You can use left- and right-distinguishing
constants to specify certain keys.
Return Value:
SHORT
4.Post Redisplay:
Syntax:
void glutPostRedisplay( );
Description:
5.Timer Function:
Syntax:
Parameters:
Description:
6.Bitmap Character:
Syntax:
Parameters:
Description:
Without using any display lists, glutBitmapCharacter renders the character in the
named bitmapfont. The available fonts are:
7.Raster Position
Syntax:
Parameters:
Description:
OpenGL maintains a 3-D position in window coordinates. This position, called the
raster position, is maintained with subpixel accuracy. It is used to position pixel and bitmap
write operations.
8.Color Function
Syntax:
Parameters:
Description:
This function randomly generates different color based on the rand() function.
9.Keyboard Function
Syntax:
Description:
glutKeyboardFunc sets the keyboard callback for the current window. When a user
types into the window, each key press generating an ASCII character will generate a
keyboard callback.
10.ShadeModel
Syntax:
Parameters:
Description:
GL primitives can have either flat or smooth shading. Smooth shading, the default,
causes the computed colors of vertices to be interpolated as the primitive is rasterized
typically assigning different colors to each resulting pixel fragment. Flat shading selects the
computed color of just one vertex and assigns it to all the pixel fragments generated by
rasterizing a single primitive
4.2 ALGORITHM
Step1: Initialize the graphics window and its size using GLUT functions.
Step 2: Register the keyboard and display call backs in main function.
Step3: When arrow keys are pressed ghosts are released from jail
Step 4: If left arrow is pressed the Pac-man move towards left in the maze eating the pebbles
simultaneously points are incremented, when points becomes 260 the game is restored.
Step 5: If right, up, down arrows is pressed Pac-man moves in respective direction eating
pebbles.
Step 6: If Pac-man eats super pebbles ghosts become edible and vulnerable function is called
Step 7: If Pac-man collides the ghosts in vulnerable state ghosts go to jail. If the ghosts are
uneaten in vulnerable state update function is called.
Step 8: If Pac-man collides with ghosts provided ghosts are not in vulnerable state Pacman
becomes edible and lives are decremented by one. If lives becomes zero the game is over.
CHAPTER 5
RESULTS
CONCLUSION
We have tried our level best to build the project efficiently and correctly and have
succeeded in building a better project, but may not be a best project. We have implemented
the required functions which we had stated earlier. After all testing process, the game is now
ready to be played.
REFERENCES
1. The Red Book-OpenGL programming Guide,6th edition.
2. Edward Angel Interactive Computer Graphics A Top-Down Approach with OpenGL,
5th edition, Addison and Wesley.
3. http://www.opengl.org/registry/
4. www.codeguru.com
5. www.openglforum.com
6. www.nehe.com.