Sie sind auf Seite 1von 38

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

Belagavi – 590 018

A
Project Report
On
“Bullz Eye”

Submitted in partial fulfillment of Bachelor of Engineering Degree


In
COMPUTER SCIENCE AND ENGINEERING
VI Semester, 15CSL68 – Computer Graphics & Visualization Lab

Submitted by
AKASH KUMAR JAIN S 1HK15CS007
N ROHIT VISHAL 1HK14CS039

Under the guidance of


Pakruddin .B
Assistant Professor, Department of Computer Science & Engineering

MAY 2018

Department of Computer Science and Engineering

HKBK COLLEGE of ENGINEERING


(Approved by AICTE & Affiliated to VTU)
Nagawara, Arabic College Post, Bangalore-45, Karnataka
Email: info@hkbk.edu.in URL: www.hkbk.edu.in
HKBK COLLEGE of ENGINEERING
Nagawara, Bangalore–560 045
Approved by AICTE & Affiliated to VTU

Department of Computer Science and Engineering

Certificate
Certified that the Project Work entitled “Bullz Eye”, carried out by AKASH
KUMAR JAIN S (1HK15CS007) and N ROHIT VISHAL (1HK14CS039) are
bonafide students of HKBK COLLEGE of ENGINEERING, in partial fulfillment
for the award of Bachelor of Engineering in Computer Science and Engineering of
the Visvesvaraya Technological University, Belgaum, during the year 2017–18. It is
certified that all corrections/suggestions indicated for Internal Assessment have been
incorporated in the report deposited in the departmental library. The project report has
been approved as it satisfies the academic requirements in respect of 15CSL68–
Computer Graphics & Visualization Lab prescribed for the said Degree.

Pakruddin .B Dr. Loganathan R


Assistant Professor Professor & HOD
Guide

External Viva

Name of the Examiners Signature with Date

1.

2.
ACKNOWLEDGEMENT

I would like to express my regards and acknowledgement to all who helped me in


completing this project successfully.

First of all I would take this opportunity to express my heartfelt gratitude to the
personalities, Mr. C M Ibrahim, Chairman, HKBKGI and Mr. C M Faiz Mohammed,
Director, HKBKGI for providing facilities throughout the course.

I express my sincere gratitude to Dr. Muzzamil Ahamed S, Principal, HKBKCE for his
support towards the attainment of knowledge.

I consider it as a great privilege to convey my sincere regards to Dr. Loganathan. R.,


Professor and HOD, Department of CSE, HKBKCE, for his constant encouragement
throughout the course of the project.

I would specially like to thank my guide Pakruddin .B, Assistant Professor, Department
of CSE, HKBKCE for his vigilant supervision and his constant encouragement. He spent
his precious time in reviewing the project work and provided many insightful comments
and constructive criticism.

Finally, I thank Almighty, all the staff members of CSE Department, my family members
and friends for their constant support and encouragement in carrying out the project work.

AKASH KUMAR JAIN S [1HK15CS007]

N ROHIT VISHAL [1HK14CS039]


ABSTRACT
Computer Graphics is concerned with all aspects of producing
pictures or images using a computer. Using computer graphics, we can
create images by computers that are indistinguishable from photographs of
real objects. We are implementing our project using a particular graphics
software system OPENGL. OpenGL is strictly defined as “a software
interface to graphics hardware.” In essence, it is a 3D graphics and
modelling library that is extremely portable and very fast.

Using OpenGL, you can create elegant and beautiful 3D graphics with
nearly the visual quality. OpenGL is intended for use with computer
hardware that is designed and optimized for the display and manipulation of
3D graphics. OpenGL is used for a variety of purposes, from CAD
engineering and architectural applications to computer-generated dinosaurs
in blockbuster movies.

This project is using OpenGL for the simulations of 3D objects of balls


floating in the air and the user using arrows allotted to him has to break the
ball’s movement. If he gets a hit his counter moves up and if he cannot
break the required number of times, he will prompted with the window of
losing, else with the prompt of winning.

iv
TABLE OF CONTENTS

TITLE PAGE i
CERTIFICATE ii
ACKNOWLEDGEMENT iii
ABSTRACT iv
TABLE OF CONTENTS v
LIST OF FIGURES vi
Chapter 1: INTRODUCTION
1.1 Overview 2
1.2 Content and Organization of Report 3
1.3 Objective 4
Chapter 2: SYSTEM REQUIREMENT AND SPECIFICATION
2.1 Functional Requirement 6
2.2 Non-Functional Requirement 6
2.3 Software Requirement 7
2.4 Hardware Requirement 7
2.5 Introduction to Environment 7
Chapter 3: DESIGN
3.1 High Level Design 10
Chapter 4: IMPLEMENTATION
4.1 Libraries Used 14
4.2 Explanation of Functions 14
4.3 User Defined Functions 15
4.4 Algorithm 22
4.5 Flowchart 22
Chapter 5: SNAPSHOTS 24
Chapter 6: CONCLUSION
6.1 Conclusion
6.2 Scope for Enhancement
BIBLIOGRAPHY
Books
Websites

v
LIST OF FIGURES
Page#
4.1 Flowchart 21
5.1 Instructions Page 23
5.2 Choice Page 24
5.3 Level 1 Page 25
5.4 Level 2 Page 26
5.5 Winner Page 27
5.6 Loser Page 28

vi
CHAPTER -1
INTRODUCTION
BullzEye Introduction

CHAPTER 1
INTRODUCTION
1.1 Overview
Graphics and processing has taken the world by storm. There were
times when a simple game would require computations of a ton and would
make it very difficult to implement.
Times change and so do our belief and understanding of our computers. We
have evolved from the times of tic-tac-toes to the ages of where games have
their own AI built into the system to deliver the best of experience a person
can have by gaming.
The bullz eye game is the earliest of the games that had been developed with
a simple concept of hitting a moving ball with arrows.
The user had a limited number of arrows and he had to finish a certain task
within the limit of arrows assigned. If he does, he wins, else he fails.
The game uses the spacebar to shoot the arrows and if there is a contact
between the ball and the arrow head, it is considered as a point.
The project uses the concepts of OpenGL 3D as the balls are represented as
spheres and have depth to them and shades of color appear for the spheres as
the lighting effects have been used on the balls making them look more
realistic and true to life.
It gives the user an nostalgic experience having to play such an easy game
with the code implementation true to his liking.
Bullz Eye has been a very famous game from the beginning of the era of
games as it emerged to be an engaging and easy to play as the instruction of
the game is simply to press a button and to rely completely on instinct.

Dept Of CSE 2 2017-18


BullzEye Introduction

1.2 Content and Organization of the Report

There are six chapters included in this report, a brief idea behind these
chapters can be summarized as follows:

Chapter-1: This chapter consists of introduction part of the report which


gives brief idea about the concept of project along with a brief description of
the all the chapters included in this report.

Chapter-2: This chapter specifies the requirements of the software and


hardware required by the program to run along with a description of the
environment where this project will work successfully.

Chapter-3: This chapter gives the flow of program that is, how the
functions are called and executed in the form of flow chart to specify the
diagrammatic view.

Chapter-4: This chapter gives the overview of how the project is


implemented and how the program will work with respect to the functions
called. It specify the libraries used in the program along with the functions
that form the program with its description in the form of comments.

Chapter-5: This chapter contains snapshots of the program output that is,
the view of output what we will get when the program is executed.

Chapter-6: The last chapter contains the conclusion part of the report along
the information about the future use or modifications of the project.

Dept Of CSE 3 2017-18


BullzEye Introduction

1.3 Objective
The bullz eye game is just a way of demonstration of the concepts of
the 3D capabilities of OpenGL using which codes and logic can be put
together and form a real life problem and simulate it onto the level of
devices.

The field of computer graphics has already got to a stage of maturity so that
its applications are being widely used. Therefore, the underlying education
in this field heavily depends on the goals and skills of the corresponding
area of application. The inclusion of computer graphics education in
Informatics Engineering courses is obviously mandatory. The results of
some succeeded experiments are referred, along with the most relevant
relationships with other disciplines. Important questions regarding the future
of computer graphics education in the scope of Informatics Engineering are
also considered.

Dept Of CSE 4 2017-18


CHAPTER -2
SYSTEM REQUIREMENTS
AND SPECIFICATION
BullzEye Requirements

CHAPTER 2

SYSTEM REQUIREMENTS AND SPECIFICATIONS

A software requirement definition is an abstract description of the services


which the system should provide, and the constraints under which the system must
operate. It should only specify the external behaviour of the system.

2.1 Functional Requirements

Functional Requirements define the internal working of the software. The

following conditions must be taken care of: The ability to perform correct operations

when corresponding keys are pressed.

2.2 Non-functional Requirements

Non-functional requirements are requirements which specify criteria that can be


used to judge the operation of the system, rather than specific behaviours. This should
be contrasted with functional requirements that specify specific behaviour or functions.
Typical non-functional requirements are reliability and scalability. Non-functional
requirements are “constraints”, “quality attributes” and “quality of service
requirements”.

Types of non-functional requirements

 Volume: Volume of a system (the total space occupied) varies depending on how the
component assemblies are arranged and connected.

 Reliability: System reliability depends on component reliability but unexpected

interactions can cause new types of failure and therefore affect the reliability of the

system.

Dept of CSE 6 2017-18


BullzEye Requirements

 Security: The security of the system (its ability to resist attacks) is a complex property

that cannot be easily measured. Attacks maybe devised that were not anticipated by the

system designers and the may use default built-insafeguard.

 Reparability: This property reflects how easy it is to fix a problem with the system
once it has been discovered. It depends on being able to diagnose the problem, access
the components that are faulty and modify or replace these components.

 Usability: This property reflects how easy it is to use the system. It depends on the

technical system components, its operators and its operating environment

2.3 Software Requirements


 Operating System : Ubuntu

 Front End : Terminal

 Coding Language :C

2.4 Hardware Requirements


 System : Pentium IV 2.4 GHz or above

 Hard Disk : 40 GB or above

 Monitor : 15 VGA color

 RAM : 256 MB or above

2.5 Introduction to Environment

OpenGL is a software interface to graphics hardware. This interface consists of


about 120 distinct commands, which you use to specify the objects and operations
needed to produce interactive three-dimensional applications.

OpenGL is designed to work efficiently even if the computer that displays the graphics
you create isn’t the computer that runs your graphics program. This might be the case if
you work in a networked computer environment where many computers are connected
to one another by wires capable of carrying digital data.

Dept of CSE 7 2017-18


BullzEye Requirements

In this situation, the computer on programs can work across a network even if the client
and server are different kinds of computers. If an OpenGL program isn’t running which
your program runs and issues OpenGL drawing commands is called the client, and the
computer that receives those commands and performs the drawing is called the server.

The format for transmitting OpenGL commands (called the protocol) from the client to
the server is always the same, so OpenGL across a network, then there’s only one
computer, and it is both the client and the server.

Dept of CSE 8 2017-18


CHAPTER -3
DESIGN
BullzEye Design

CHAPTER 3
DESIGN

Requirement analysis encompasses all the tasks that go into the instigation, scoping and
definition of a new or altered system. Requirement analysis is an important part of the design
process. Here we identify the needs or requirements. Once the requirements have been identified
the solution for the requirements can be designed.

We a design a project with specific goals, tasks and outcomes. The more specific and the
more closely aligned with traditional instructional objectives, the better.

3.1 High Level Design


High Level Design (HLD) is the overall system design - covering the system architecture
and database design. It describes the relation between various modules and functions of the
system. Data flow, flow charts and data structures are covered under HLD.

The different modules used in this project are as follows:

1. glutInit( int *argcp, char **argv);


The argument 'argcp' is a pointer to the program’s unmodified 'argv' variable from main. Upon
return, the value pointed to by 'argcp' will be updated, because glutInit extracts any command
line options intended for the GLUT library 'argv'. Like argcp, the data for argv will be updated
because glutInit extracts any command line options understood by the GLUT library.

2. glutInitDisplayMode(unsigned int mode);


It sets the initial display mode. The argument 'mode' is the display mode, normally the bitwise
OR-ing of GLUT display mode bit masks.

See values below:


• GLUT SINGLE : Bit mask to select a single buffered window. This is the default if neither
GLUT_DOUBLE or GLUT_SINGLE are specified.
• GLUT RGB : Bit mask to select a RGBA mode window.

3. glutSwapBuffers(void);
Performs a buffer swap on the layer in use for the current window.

Dept of CSE 10 2017-18


BullzEye Design

4. glutMainLoop(void);
The module glutMainLoop enters the GLUT event processing loop. This routine should be called
atmost once in a GLUT program. Once called, this routine will never return. It will call as
necessary any callbacks that have been registered.

5. glutCreateWindow(char *name);
This creates a top-level window. The argument 'name' is provided to the system as the window's
name with the intent that the window system will label the window with the name.

6. glutDisplayFunc(void (*func)(void));
Sets the display callback for the current window. The 'func' is the new display callback function.

7. glLoadIdentity(void);
It replaces the current matrix with the identity matrix. It is semantically equivalent to calling
glLoadMatrix with the 4X4 identity matrix.

8. glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf


alpha);
Specifies the red, green, blue, and alpha values used when the color buffers are cleared. The
intial values are all 0. Values specified by glClearColor are clamped to the range [0-1].

9. glutReshapeFunc(void (*func)(int width, int height));


This sets the reshape callback for the current window. The reshape callback is triggered when a
window is reshaped. A reshape callback is also triggered immediately before a window's first
display callback after a window is created or whenever an overlay for the window is established.

10. gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear,


GLdouble zFar);
The parameter 'fovy' specifies the field of view angle in the y direction, 'aspect' specifies the
aspect ratio that determines the field in the x direction, 'zNear' specifies the distance from the
viewer to the near clipping plane and 'zFar' specifies the distance from the viewer to the far
clipping plane.This module specifies a viewing frustum into the world coordinate system.

Dept of CSE 11 2017-18


BullzEye Design

11. glViewport(GLint x, GLint y, GLsizei width, GLsizei height);


The parameters ‘x’, ‘y’ specify the lower left corner of the viewport rectangle, in pixels. The
parameters ‘width’, ‘height’ specify the width and height of the viewport
glViewport specifies the affine transformation of x and y from normalized device coordinates to

window coordinates.

12. glTranslatef(GLfloat x, GLfloat y, GLfloat z);


The parameters ‘x’, ‘y’, ‘z’ specify the x, y, and z coordinates of a translation vector. This
produces a translation by x, y, z. The current matrix is multiplied by this translation matrix, with
the product replacing the current matrix.

13. glScaled(GLdouble x, GLdouble y, GLdouble z);


The parameters ‘x’, ‘y’, ‘z’ specify the scale factors along the x, y, and z axes, respectively. This
produces a nonuniform scaling along the x, y, and z axes.

Dept of CSE 12 2017-18


CHAPTER -4
IMPLEMENTATION
BullzEye Implementation

CHAPTER 4

IMPLEMENTATION

Implementation is the process of putting a decision into effect. It is an act or instance of


implementing something that is, the process of making something active or effective.
Implementation must follow any preliminary thinking in order for something to actually happen.
In the context of information technology, implementation encompasses the process involved in
getting new software or hardware to operate properly in its environment. This includes
installation, configuration, running, testing and making necessary changes. The word deployment
is sometime used to mean the same thing.

4.1 Libraries Used

OpenGL function names begin with the letters gl and are stored in a library usually

referred to as GL (or OpenGL in Windows). The first is the OpenGL Utility Library (GLU).

This library uses only GL functions but contains code for creating common objects, such as

spheres, and other tasks that users prefer not to write repeatedly. The GLU library is available in

all OpenGL implementations. The second library addresses the problems of interfacing with the

window system. We use a readily available library called the

OpenGL Utility Toolkit (GLUT) that provides the minimum functionality that should be
expected in any modern windowing system. The GLX library provides the minimum “glue”
between OpenGL and the XWindow System. GLX is used by GLUT, and thus this library and
various others are called from the OpenGL libraries, but the application program does not need to
refer to these libraries directly. Strings such as GL_FILL and GL_POINTS are defined in header
(.h) files. In most implementations, one of the “include” lines.

4.2 Explanation of Functions

glTranslatef: Alters the current matrix by a displacement of (x,y,z). TYPE is either GLfloat or
GLdouble.hg .

Dept of CSE 14 2017-18


BullzEye Implementation

glMatrixMode: Sets the current matrix mode. Mode can assume one of four values:
• GL_MODELVIEW -Applies subsequent matrix operations to the model view matrix stack.
• GL_PROJECTION -Applies subsequent matrix operations to the projection matrix stack.
• GL_TEXTURE -Applies subsequent matrix operations to the texture matrix stack.

• GL_COLOR -Applies subsequent matrix operations to the color matrix stack.

glPushMatrix and glPopMatrix: Pushes to and pops from the matrix stack corresponding to the
current matrix mode.

glBegin: Initiates a new primitive of type mode and starts the collection of vertices. Values of

mode include GL_POINTS, GL_LINES and GL_POLYGON.

glEnd: Terminates a list of vertices.

4.3 User Defined Functions


A programmed routine that has its parameters set by the user of the system. User defined
functions often are seen as programming shortcuts as they define functions that perform specific
tasks within a larger system, such as a database or spreadsheet program.

4.3.1 Init Function


void init(void)

{
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_shininess[] = { 100.0 };
GLfloat mat_diffuse[]={ 1.0,1.0,1.0,1.0};
GLfloat mat_ambient[]={0.0,0.0,0.0,1.0};
GLfloat light_position[] = { 1.0, 1.0, 0.0, 0.0 };
glClearColor (1.0, 1.0, 0.0, 1.0);
glShadeModel (GL_SMOOTH);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_COLOR_MATERIAL);

Dept of CSE 15 2017-18


BullzEye Implementation

}
4.3.2 Drawhit Function
void drawhit(const char * message, int x, int y)
{
glPushMatrix();
glScalef(0.07,0.06,0.15);
glTranslatef(x,y,0);
while (*message)
{
glutStrokeCharacter(GLUT_STROKE_ROMAN,*message++);
}
glPopMatrix();
}
4.3.3 Myhit Function
void myHit()
{
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,200,0,200);
glMatrixMode(GL_MODELVIEW);
glClearColor(1.0,1.0,0.0,1.0);
glColor3f(0.0,0.8,0.8);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
glLineWidth(4.0);
drawhit("WINNER!!",1125,2000);
}
4.3.4 Draw Instruction Function
void draw_instruct(const char *message, int x, int y)
{
int j;
glPushMatrix();
glScalef(0.063,0.07,0.0);
glTranslatef(x,y,0);
while (*message)
{
glutStrokeCharacter(GLUT_STROKE_ROMAN,*message++);
}
for(j=0;j<10000;j++);
glPopMatrix();
}
4.3.5 Instruction Function
void instructions()
{
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

Dept of CSE 16 2017-18


BullzEye Implementation

gluOrtho2D(0,200,0,200);
glMatrixMode(GL_MODELVIEW);
glClearColor(1.0,1.0,0.0,1.0);
glColor3f(1.0,0.0,1.0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH); glLineWidth(3.0);
draw_instruct("HKBK College of Engineering",600,2600);
draw_instruct("Department of Computer Science",400,2400);
draw_instruct("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",0,1850);
draw_instruct("Mini-Project with OpenGL",700,2200);
draw_instruct("BULLZ-EYE with OpenGL",700,2000);
draw_instruct("By:",1400,1700);
draw_instruct("Akash Kumar Jain S (1HK15CS007)",400,1500);
draw_instruct("N Rohit Vishal (1HK14CS039)",600,1300);
draw_instruct("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",0,850);
draw_instruct("Guided by Asst. Professor Pakaruddin Basha",180,1000);
draw_instruct("Welcome to BULLZ-EYE",700,700);
draw_instruct("Press Enter. Left click on mouse to play",250,500);
draw_instruct("Press Space to shoot",800,300);
glFlush();
}
4.3.6 Display Function
void display1()

int i;
if(counter1==1)
{
display2();
glFlush();
}
else
{ int j;
for(j=0;j<10000;j++);
glClearColor(1.0,1.0,1.0,1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glColor3f(1, 1, 0);
glRasterPos2f(-0.9, 0.9);
sprintf(tmp_str, "Arrow count: %d", count);
Write(tmp_str);
glPopMatrix();
if(count>=30)
glutDisplayFunc(displost);
glPushMatrix();
glColor3f(1, 1, 0);
glRasterPos2f(-0.2, 0.9);

Dept of CSE 17 2017-18


BullzEye Implementation

sprintf(tmp_str, "Score: %d", counter1);


Write(tmp_str);
glPopMatrix();
glPushMatrix();
glColor3f(1.0,0.0,0.0);
glLoadIdentity();
glTranslatef(0.8,-0.869+up,0.0);
glutSolidSphere(0.13,20,16);
if(shoot==1)
{
glPushMatrix();
glLoadIdentity();
glTranslatef(-0.8+pos,0.0,0.0);
glColor3f(0.0,0.0,0.0);
glLineWidth(2.0);
glBegin(GL_LINES);
glVertex3f(-0.2,0.0,0.0);
glVertex3f(0.1,0.0,0.0);
glVertex3f(0.1,0.0,0.0);
glVertex3f(0.03,0.05,0.0);
glVertex3f(0.1,0.0,0.0);
glVertex3f(0.03,-0.05,0.0);
glEnd();
glPopMatrix();
}
if(bang==1)
{
bang=0;pos=-0.2;
glPushMatrix();
glLoadIdentity();
up=0;
glColor3f(1.0,0.0,0.0);
glutSolidSphere(1,20,16);
glPopMatrix();
}
glPopMatrix();
for( i=0;i<200;i=i+20)
{
if(pos>=1.74 && up>0.825 && up<0.975)
{
counter1 ++;
for(j=0;j<10000;j++);
shoot=0;
pos=-0.2;
bang=1;
}
if(counter1==3)
count=0;
up=(up+0.0003);

Dept of CSE 18 2017-18


BullzEye Implementation

if(up>2)
up=0;
if(shoot==1)
{
pos=pos+0.0005;
if(pos>2)
{
pos=-0.2;
shoot=0;
}
}
glutPostRedisplay();
glFlush();
}
}
}
4.3.7 Display2 Function
void display2()
{
int i;
if(counter2==1)
{
myHit();
glFlush();
}
else
{
int j;
for(j=0;j<10000;j++);
glClearColor(1.0,1.0,1.0,1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glPushMatrix();
glColor3f(1, 1, 0);
glRasterPos2f(-0.9, 0.9);
sprintf(tmp_str, "Arrow count: %d", count);
Write(tmp_str);
glPopMatrix();
if(count>=20)
glutDisplayFunc(displost);
glPushMatrix();
glColor3f(1, 1, 0);
glRasterPos2f(-0.2, 0.9);
sprintf(tmp_str, "Score: %d", counter2);
Write(tmp_str);
glPopMatrix();
glPushMatrix();
glColor3f(1.0,0.0,0.0);

Dept of CSE 19 2017-18


BullzEye Implementation

glLoadIdentity();
glTranslatef(0.8,-0.769+up,0.0);
glutSolidSphere(0.10,20,16);
glColor3f(0.0,0.0,1.0);
glPushMatrix();
glColor3f(0.0,0.0,1.0);
glLoadIdentity();
glTranslatef(0.4,0.769-up,0.0);
glutSolidSphere(0.10,20,16);
glColor3f(0.0,0.0,1.0);
if(shoot==1)
{
glPushMatrix();
glLoadIdentity();
glTranslatef(-0.8+pos,0.0,0.0);
glColor3f(0.0,0.0,0.0);
glLineWidth(2.0);
glBegin(GL_LINES);
glVertex3f(-0.2,0.0,0.0);

glVertex3f(0.1,0.0,0.0);
glVertex3f(0.1,0.0,0.0);
glVertex3f(0.03,0.05,0.0);
glVertex3f(0.1,0.0,0.0);
glVertex3f(0.03,-0.05,0.0);
glEnd();
glPopMatrix();
}
if(bang==1)
{
bang=0;
pos=-0.2;
glPushMatrix();
glLoadIdentity();
up=0;
glColor3f(1.0,0.0,0.0);
glutSolidSphere(1,20,16);
glPopMatrix();
}
glPopMatrix();
for( i=0;i<200;i=i+20)
{
if(pos>=1.75 && up>0.825 && up<0.975)
{
counter2 ++;
for(j=0;j<10000;j++);
shoot=0;
pos=-0.2;

Dept of CSE 20 2017-18


BullzEye Implementation

bang=1;
}
up=(up+0.0003);
if(up>2)
up=0;
if(shoot==1)
{
pos=pos+0.0005;
if(pos>2)
{
pos=-0.2;
shoot=0;
}
}
glutPostRedisplay();
}
}
glFlush();
}
4.3.8 Display Lost Function
void displost()
{
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,200,0,200);
glMatrixMode(GL_MODELVIEW);
glClearColor(1.0,1.0,0.0,1.0);
glColor3f(0.0,0.8,0.80);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
glLineWidth(4.0);
drawhit("YOU LOST!!",1100,2000);
glFlush();
}
4.3.9 Keyboard Function
void keyboard(unsigned char key,int x,int y)

{
if (key==32)
{
shoot=1;
count++;
}
if(key==13)
{
glutInitDisplayMode(GLUT_DEPTH|GLUT_RGB);

Dept of CSE 21 2017-18


BullzEye Implementation

glutInitWindowSize(700,700);
glutInitWindowPosition(300,0);
game=glutCreateWindow("Bullz Eye");
init(); 17
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutCreateMenu(choose);
glutAddMenuEntry("PlayLevel1",1);
glutAddMenuEntry("PlayLevel2",2);
glutAddMenuEntry("Quit",3);
glutAttachMenu(GLUT_LEFT_BUTTON);
}
}
4.4 Algorithm
1. Start
2. Display instruction() window.
3. If “enter” is hit, create the game window. Else wait.
4. If LEFT MOUSE CLICK,
5. Switch 1: Play level 1. If win, move to level 2, else displost().
6. Switch 2: Play level 2. If win, display win prompt, else displost().
7. Switch 3: Quit game.
8. End.

4.5 Flowchart

Fig:4.1

Dept of CSE 22 2017-18


CHAPTER -5
SNAPSHOTS
BullzEye Snapshots

CHAPTER 5

SNAPSHOTS

Fig:5.1 Welcome Page

Dept of CSE 24 2017-18


BullzEye Snapshots

Fig:5.2 Choice Page

Dept of CSE 25 2017-18


BullzEye Snapshots

Fig:5.3 Level 1 Page

Dept of CSE 26 2017-18


BullzEye Snapshots

Fig:5.4 Level 2 Page

Dept of CSE 27 2017-18


BullzEye Snapshots

Fig:5.5 Winner Page

Dept of CSE 28 2017-18


BullzEye Snapshots

Fig:5.6 Loser Page

Dept of CSE 29 2017-18


CHAPTER -6

CONCLUSION AND
FUTURE SCOPE
CHAPTER 6
CONCLUSION AND FUTURE SCOPE
6.1 Conclusion
Our project "Bullz Eye" encompasses a broad range of OpenGL
functionalities. We have made of concepts learnt in theory including 3D
representation, texturing, shading etc. and so on. This program also uses
keyboard events to implement all the options provided that is, shoot and
choose options.

The goal of this project was to get a first-hand experience of OpenGL


programming. This was achieved by the successful completion of the
project. Thus this program was effectively implemented as required by the
user software requirements. The program is user friendly and provides the
necessary options to the user whenever required. The software is developed
with a simple interface.

6.2 Future Scope

 The graphics of the game can be enhanced further by implementing many


other methods of different graphics packages.

 The game can further be divided into levels where the user has the liberty to
choose what kind of difficulty he or she would want such as the arrows
being very limited for a particular kind of level.

 Many kinds of interactive levels can be made upon the concept of bullz eye.
Bibliography
[1] W.S.N.p., Internet of Things: Wireless Sensor Networks. IEC Market Strategy Board,
2014.
[2] Akyildiz, I.F. and M.C. Vuran, Wireless sensor networks. Vol. 4. 2010: John Wiley &
Sons.
[3] Fisher, R., et al., Open Hardware: A Role to Play in Wireless Sensor Networks?
Sensors (Basel), 2015. 15(3): p. 6818-44.
[4] Yong, W., G. Attebury, and B. Ramamurthy, A survey of security issues in wireless
sensor networks. Communications Surveys & Tutorials, IEEE, 2006. 8(2): p. 2-23.
[5] Al-Fuqaha, A., et al., Internet of Things: A Survey on Enabling Technologies,
Protocols, and Applications. Communications Surveys & Tutorials, IEEE, 2015.
17(4): p. 2347-2376.
[6] www.youtube.com
[7] www.google.co.in
[8] www.wikipedia.com
[9] www.github.com

Das könnte Ihnen auch gefallen