Beruflich Dokumente
Kultur Dokumente
A
Project Report
On
“Bullz Eye”
Submitted by
AKASH KUMAR JAIN S 1HK15CS007
N ROHIT VISHAL 1HK14CS039
MAY 2018
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.
External Viva
1.
2.
ACKNOWLEDGEMENT
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 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.
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.
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.
There are six chapters included in this report, a brief idea behind these
chapters can be summarized as follows:
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-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.
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.
CHAPTER 2
following conditions must be taken care of: The ability to perform correct operations
Volume: Volume of a system (the total space occupied) varies depending on how the
component assemblies are arranged and connected.
interactions can cause new types of failure and therefore affect the reliability of the
system.
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
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
Coding Language :C
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.
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.
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. glutSwapBuffers(void);
Performs a buffer swap on the layer in use for the current window.
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.
window coordinates.
CHAPTER 4
IMPLEMENTATION
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
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.
glTranslatef: Alters the current matrix by a displacement of (x,y,z). TYPE is either GLfloat or
GLdouble.hg .
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.
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
{
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);
}
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();
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);
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);
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;
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);
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
CHAPTER 5
SNAPSHOTS
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 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