0% found this document useful (0 votes)
93 views11 pages

Packman 2

This document provides an overview of computer graphics and the OpenGL graphics library. It discusses how OpenGL serves as a hardware-independent interface for programming 3D graphics applications. The document describes the basic components of the OpenGL graphics pipeline including vertex operations, primitive assembly, rasterization, and fragment operations. It then discusses the goals and scope of developing a 3D Pac-Man game project using OpenGL. Key aspects of the Pac-Man game such as movement, collision detection, and the basic gameplay are also summarized.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views11 pages

Packman 2

This document provides an overview of computer graphics and the OpenGL graphics library. It discusses how OpenGL serves as a hardware-independent interface for programming 3D graphics applications. The document describes the basic components of the OpenGL graphics pipeline including vertex operations, primitive assembly, rasterization, and fragment operations. It then discusses the goals and scope of developing a 3D Pac-Man game project using OpenGL. Key aspects of the Pac-Man game such as movement, collision detection, and the basic gameplay are also summarized.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

PackMan_Report.

docx

1 / 40

CHAPTER 1

INTRODUCTION

1.1 Computer Graphics


1.2

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 world objects but also of abstract, synthetic objects, such as
mathematical surfaces and of data that have no inherent geometry, such as survey results.

1.3 OpenGL
1.4

OpenGL (Open Graphics Library) is a standard specification defining a cross language cross 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 3D scenes from simple primitives. OpenGL
was developed by Silicon Graphics Inc. (SGI) in 1992 and is widely used in CAD, virtual reality, scientific
visualization, information visualization and flight simulation. It is also used in video games, where it
competes with direct 3D on Microsoft Windows Platforms.OpenGL is managed by the non profit
technology consortium, the Khronos group Inc.

OpenGL serves two main purposes :

Ø To hide the complexities of interfacing with different 3D accelerators, by presenting programmer with
a single, uniform API

Ø To hide the differing capabilities of hardware platforms , by requiring that all implementations support
the full OpenGL feature set.
2 / 40
3 OpenGL has historically been influential on the development of 3D accelerator, promoting a base
level of functionality that is now common in consumer level hardware:

Ø Rasterized points, lines and polygons are basic primitives.

Ø A transform and lighting pipeline .

Ø Z buffering .

Ø Texture Mapping.

Ø Alpha Blending.

OpenGL Graphics Architecture :

Fig 1.1 openGl Graphics Architecture

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.

4 / 40
5

Ø 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.

Ø Primitive Assembly :

Clipping, a major part of primitive assembly, is the elimination of portions of geometry which fall outside
a half space, defined by a plane.

Ø 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.

1.3 Project Goal

The aim of this project is to develop a 3D Game which supports basic operations

4 / 40

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

It is developed in ECLIPSE. It has been implemented on UBUNTU platform. The 3-D graphics package
designed here provides an interface for the users for handling the display and manipulation of Pac-Man
Movements. The Keyboard is the main input device used.

Pac-Man :

The game was developed primarily by a young Namco employee Tōru Iwatani, over a year, beginning in
April of 1979, employing a nine-man team. The original title was pronounced pakku-man and was
inspired by the Japanese onomatopoeic phrase paku-paku taberu where paku-paku describes (the
sound of) the mouth movement when widely opened and then closed in succession.

Although it is often cited that the character’s shape was inspired by a pizza missing a slice, he admitted
in a 1986 interview that it was a half-truth and the character design also came from simplifying and
rounding out the Japanese character for mouth, kuchi as well as the basic concept of eating. Iwatani’s
efforts to appeal to a wider audience beyond the typical demographics of young boys and teenagers-
eventually led him to add elements of a maze.
The result was a game he named Puck Man.

CHAPTER 2

LITERATURE SURVEY

The Pac-Man game has its roots as a Japanese arcade game developed by Namco (now Namco Bandai)
and licensed for distribution in the U.S. by Midway, first released in Japan on

6 / 40
7 May 22, 1980. Pac-Man is universally considered as one of the classics of the medium, virtually
synonymous with video games, and an icon of 1980s popular culture. When it was released, the
game became a social phenomenon.

The Pac-Man game is often credited with being a landmark in video game history, and is among the
most famous arcade games of all time. The character also appears in more than 30 officially licensed
games asequels, as well as in numerous unauthorized clones and bootlegs.

Basic Working Of Pac-Man :

The player controls Pac-Man through a maze, eating dots. When all dots are eaten, Pac-Man game is
over. Four ghosts roam the maze, trying to catch Pac-Man. If a ghost touches Pac-Man, a life is lost.
When all lives have been lost, the game ends. Near the corners of the maze are four larger, flashing dots
known as “Energizers” or “Power Pills”, which provide Pac-Man with the temporary ability to eat the
ghosts.

The ghosts turn deep blue, reverse direction, and usually move more slowly till it returns to the normal
state. When Pac-Man eats ghost during vulnerable state, ghost traverses back to the jail and re-
initializes to start a new attack. Collision Detection for Pac-Man and Ghost, and Artificial Intelligence for
Ghost has been implemented. A total of 260 points are assigned (1 point for normal pebble and 5 points
for super pebble) and max lives of 3 is being setup with a 3-D Maze.

Related Data Structure :


Package uses data structures like Stack for storing the co-ordinates of primitives and also uses Arrays
for storing the pixel values.

CHAPTER 3

HARDWARE AND SOFTWARE REQUIREMENTS

3.1 Hardware Requirements

Ø Pentium or higher processor.

Ø 512 MB or more RAM.

6 / 40

3.2 Software Requirements

This graphics package has been designed for UBUNTU Platform and uses ECLIPSE integrated
environment.

Development Platform

UBUNTU 10.10

Development tool

ECLIPSE

Language Used In Coding

C++
CHAPTER 4

DESIGN

4.1 Proposed System

To achieve three dimensional effects, OpenGL software is proposed. It is software which provides a
graphical interface. It is an interface between application program and graphics hardware. The
advantages are:

Ø OpenGL is designed as a streamlined.

Ø It is a hardware independent interface, it can be implemented on many different hardware platforms.

Ø With OpenGL, we can draw a small set of geometric primitives such as points, lines and polygons etc.

8 / 40
9 Ø It provides double buffering which is vital in providing transformations.

Ø It is event driven software.

Ø It provides call back function.

Detailed Design

Transformation Functions Ø Translation:

Translation is done by adding the required amount of translation quantities to each of the points of the
objects in the selected area. If P(x,y) be the a point and (tx, ty) translation quantities then the translated
point is given by glTranslatef(dx,dy,dz) ;

Ø Rotation:

The rotation of an object by an angle ‘a’ is accomplished by rotating each of the points of the object.
The rotated points can be obtained using the OpenGL functions glRotatef(angle, vx,vy,vz); Ø Scaling:

The scaling operation on an object can be carried out for an object by multiplying each of the points
(x,y,z) by the scaling factors sx, sy and sz.

glScalef(sx,sy,sz);

CHAPTER 5

IMPLEMENTATION

5.1 User Defined Functions:


Function for pacman:

Pacman_Move ( )

Both the x and y updated coordinates are calculate

Using the speed of the pacman and trigonometric functions.

Pacman_Draw()

8 / 40

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.

Collision Detection For Pac-Man And Ghost:

Bool open()

Here, the condition to check if the board is open is given.

This is used for collision detection.

Function for Monsters:

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.

10 / 40
11 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.

Function for Board:

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.

10 / 40

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.
}

In Built Functions Used

Ø PushMatrix And PopMatrix

Syntax: glPushMatrix( );

glPopMatrix( );

Description:

Pushes the current transformation matrix onto the matrix stack. The glPushMatrix() function saves the
current coordinate system to the stack and glPopMatrix() restores the prior coordinate system.

Ø Solid Sphere

Syntax:

Void glutSolidSphere (GLdouble radius , Glint slices, Glint stacks);

12 / 40
13 Parameters:

Radius: The radius of the sphere.

Slices: The number of subdivisions around the Z axis (similar to


Lines of longitude).

Stacks: The number of subdivisions along the Z axis (similar to Lines of


latitude).

Description:

Renders a sphere centered at the modeling coordinates origin of the specified radius. The
sphere is subdivided aroundthe Z axis into slices and along the Z axis into stacks.

Get Async KeyState Function : Syntax:

SHORT GetAsyncKeyState( int vKey);


Parameters: vKey [in] int;

Specifies one of 256 possible key codes. You can use left- and right-distinguishing constants to specify
certain keys.

Description:

The GetAsyncKeyState function determines whether a key is up or down at the time the function is
called, and whether the key was pressed after a previous call to GetAsyncKeyState.

Return Value:

SHORT

Ø Post Redisplay :

Syntax:

You might also like