Professional Documents
Culture Documents
Batch 25 Bullz Eye
Batch 25 Bullz Eye
Batch 25 Bullz Eye
2020-21
On
BULLZ EYE
SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENT IN 6TH SEMESTER
IN
By
Prof. Ambika K B
Assistant Professor
Dept. of CSE, VVIET
CERTIFICATE
Certified that the MAD Mini Project Work entitled “Bullz Eye ” carried out by PRIYANKA
GAVAROJI [4VM18CS031] and YASHASWINI KN [4VM18CS047], bonafide students of VVIET in
partial fulfillment for the award of degree Bachelor of Engineering in COMPUTER SCIENCE and
ENGINEERING as prescribed by VISVESVARAYA TECHNOLOGICAL UNIVERSITY, BELGAUM
during the academic year 2020-21. 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 mini project work
prescribed for the said degree.
1.
2.
ACKNOWLEDGEMENT
We would like to thank and express our heartfelt gratitude to God almighty for the
abundant blessings without which this project would not have been successful.
We would like to express our sincere gratitude to Sri. Vasu, Chairman of VVIET,
Mr. Kaveesh Gowda V, Secretary of VVIET and all management members of VVIET, for their
constant support.
We would like to express our deepest sense of gratitude towards Dr. Madhu B K, Head
of the Department, CSE, VVIET, Mysuru for his valuable suggestions, support and
encouragement.
We would like to extend our heartfelt gratitude to Mr. Theja N, Assistant Professor,
Dept. of CSE, for the valuable guidance and advice. We would also like to thank him for his
guidance and useful suggestions, which helped us in completing the project work on time.
We would also thank all other teaching and non-teaching staffs of the Computer
Science Department who has directly or indirectly helped us in completion of this project.
Our thanks and appreciation also go to our family and friends who have willingly helped
us out with their abilities.
Regards,
PRIYANKA GAVAROJI
YASHASWINI K N
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 of3D 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.
TABLE OF CONTENTS
Acknowledgement i
Abstract ii
List of Figures 5
1. Introduction 1-3
1.1 Overview 1
1.3 Objectives 3
4. Design 8-11
4.1 High level design 8
5. Implementation 11-19
5.4 Algorithm 18
6. Snapshots 20-23
7. Coding 24-39
8. Conclusion 40
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.
How to play
This game has two levels
• 1st level-The main aim is to strike the balls thrice within the given number of arrows which
is 30.Upon winning this the user moves to the next level. If the user is unable to accomplish
this he loses the game.
• The user can directly jump to the second level without playing the first level.
• 2nd level-The main aim is to strike the balls thrice within the given number of arrows which
is 20.If the user is unable to accomplish this he loses the game.
1.2 INTRODUCTION TO OPENGL
Most of our application will be designed to access OpenGL directly through functions in
three libraries. Functions in the main GL (or OpenGL in windows) library have names that
begin with the letters gl and are stored in a library usually referred to as GL (or OpenGL in
windows).
The second is the OpenGL Utility Library (GLU). This library uses only GL functions but
contains code for creating common objects and simplifying viewing. All functions in GLU
can be created from the core GL library but application programmers prefer not to write the
code repeatedly. The GLU library is available in all OpenGL implementations; functions in
the GLU library begin with letters glu.
To interface with the window system and to get input from external devices into our
programs, we need at least one more system-specific library that provides the “glue” between
the window system and OpenGL. For the X window system, this library is functionality that
should be expected in any modern windowing system.
Fig 2.1 shows the organization of the libraries for an X Window System environment.
For this window system, GLUT will use GLX and the X libraries. The application program,
however, can use only GLUT functions and thus can be recompiled with the GLUT library
for other window systems.
GLU
GL Frame
OpenGL Buffer
application Xlib, Xtk
Program
GLUT
GLX
OpenGL commands use the prefix gl and initial capital letters for each word making up the
command name. Similarly, OpenGL defined constants begin with GL_, use all capital letters
and use underscores to separate words (like GL_COLOR_BUFFER_BIT).
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
LITERATURE SURVEY
The OpenGL Programming Guide - The Redbook
The OpenGL Programming Guide 5th Edition The Official Guide to Learning
OpenGL Version 2.1
The OpenGL Programming Guide, Fifth Edition, provides definitive and comprehensive
information on OpenGL and the OpenGL Utility Library. The previous edition covered OpenGL
through Version 1.3 and 1.4. This fifth edition of the best-selling "red book" describes the latest
features of OpenGL Versions 1.5 and 2.0, including the introduction of the OpenGL Shading
Language. You will find clear explanations of OpenGL functionality and many basic computer
graphics techniques, such as building and rendering 3D models; interactively viewing objects
from different perspective points; and using shading, lighting, and texturing effects for greater
realism. In addition, this book provides in-depth coverage of advanced techniques, including
texture mapping, antialiasing, fog and atmospheric effects, NURBS, image processing, and more.
The text also explores other key topics such as enhancing performance, OpenGL extensions, and
cross-platform techniques. This fifth edition has been extensively updated to include the newest
features of OpenGL, versions 1.5 and 2.0.
www.opengl.org for OpenGL tutorials
Pervisim offers consulting and software development for visualization leveraging OpenGL
Pervisim is a new consulting and software development firm located in Cary, NC that
specializes in 3D visualization applications. Recently completed and revived projects include
mashup visualizations that create terrain visualizations in 3D pdf and molecular modeling
using OpenGL.
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.
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-in safeguard.
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.
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.
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 4
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.
• 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.
4. glutMainLoop(void);
The module glutMainLoop enters the GLUT event processing loop. This routine should be
called at most 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
callingglLoadMatrix with the 4X4 identity matrix.
8. glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampfalpha);
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.
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 viewportglViewport
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’ s pacify the scale factors along the x, y, and z axes, respectively.
This produces a no uniform scaling along the x, y, and z axes.
SOFTWARE DESIGN
This project has been created using the OpenGL interface along with the GLUT( OpenGL
Library Toolkit), using the platform Eclipse as the compiling tool. This game has been
designed in a simple and lucid manner so that further developments can be made, and run on
many platforms with a few changes in the code.
We begin our game by providing a simple menu option upon right click of the mouse to
display 2 levels of the game which the user can choose, and a third option to exit the game.
Upon selecting the first level, a red ball is continuously produced and moves upwards at the
right side of the screen. Hitting the ‘f’ key on the keyboard produces an arrow, which the user
must aim to hit the balls with. On successful contact with the ball, the game registers it as a
‘HIT’ and increments a counter variable. A count of 3 (i.e 3 hits) takes the player to the next
level of the game.
Level 2 increases the difficulty level by producing2 colours of balls- a blue one and a red one.
While the red is as before produced continuously and moves from bottom to top, the blue one
moves from top to bottom at irregular intervals to confuse the player. The player needs to aim
correctly and target only the red ones. Player needs to again score a minimum of 3 ‘hits’ to be
a Winner.
Level 2 can be directly entered in the beginning itself ( without playing level 1). We provide
this option so that the player can choose his difficulty level.
The underlying logic of the game is Collision detection. The bounds of the ball are detected
with the bounds, or the continuously changing position of the arrow head. 2 variables ‘pos’
(for the arrowhead) and ‘up’ (for the ball) are kept tab of, and are updated with their changing
Values
If the given position vector does intersect with the current value of the ‘up’, we infer that a
collision has been detected and register it as a hit, and increment ‘counter’. Other wise the
function returns a NULL.
Once a ‘hit’ takes place, we call a Sleep() timer ( as buffers are too fast to see the collision in
our game), show the ball burst ( without particle effect or engines) and reset the ball to its
initial position and the cycle starts all over again.
Careful observation of these values have been made while developing the game.
To model the objects as 3D entities we also use the effects of lighting in our game via 4
different mechanisms:
AMBIENT - light that comes from all directions equally and is scattered in all directions
equally by the polygon.
DIFFUSE - light that comes from a point source and hits surfaces with an intensity that
depends on whether they face towards the light or away from it. SPECULAR - light is
reflected more in the manner of a mirror where most of the light bounces off in a particular
direction defined by the surface shape.
EMISSION - the light is actually emitted by the polygon - equally in all directions.
Texture is yet another feature we have implemented to show the material properties of the
object, in whichever small way we could.
CHAPTER 5
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
deployments sometime used to mean the same thing.
glTranslatef
Alters the current matrix by a displacement of (x,y,z). TYPE is either GLfloat orGLdouble.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.
• 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.
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_DIFFU
SE);glEnable(GL_LIGHTING);glEnable(GL_LIGHT0);glEnable(GL_DEPTH_TEST);glE
nable(GL_COLOR_MATERIAL);
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_SMOO
TH); 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("Ak
ash 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();}
void display1()
{
int
i;if(counter1==1){display2();glFlush();}else{ int j;for(j=0;j<10000;j++);glClear
Color(1.0,1.0,1.0,1.0);glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUF
FER_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);
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();glLoa
dIdentity();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);glutSolidSph
ere(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);
if(up>2)up=0;if(shoot==1){pos=pos+0.0005;if(pos>2){pos=-
0.2;shoot=0;}}glutPostRedisplay();glFlush();}}}
Main():
The main function performs the required initializations and starts the event processing loop. All
the functions in GLUT have the prefix glut, and those which perform some kind of initialization
have the prefix glutInit.
• glutInit(int *argc, char **argv) - parameters are pointers to the unmodified argc and argv
variables from the main function.
• We establish the window's position by using the function glutInitWindowPosition.
• We choose the window size using the function glutInitWindowSize.
• We define the display mode using the function glutInitDisplayMode. GLUT_RGB -
selects a RGBA window. This is the default color mode. GLUT_SINGLE – selects a
single buffer window.
• Each window can be created with glutCreateWindow. The return value of
glutCreateWindow is the window identifier.
• glutDisplayFunc() passes the name of the function to be called when the window needs to
be redrawn.
• glutKeyboardFunc- is notify the windows system which function(s) will perform the
required processing when a key is pressed. This function is to register a call-back for
keyboard events that occur when you press a key.
• Creating a menu: glutCreateMenu creates a menu table on a default right click of mouse.
glutAddMenuEntry adds a menu entry to this menu created.
• When we are ready to get in the application event processing loop we enter
glutMainLoop. It gets the application in a never ending loop, always waiting for the next
event to process
5.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.
5.5 Flowchart Fig:4.1
CHAPTER 6
SNAPSHOTS
Welcome page
Choice page
Level 1 Page
Level 2 Page
Winner Page
Loser Page
CHAPTER 7
CODING
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<GL/glut.h>
#include<time.h>
#include<math.h>
//#include<windows.h>
int shoot=0,bang=0;
int counter1=0,counter2=0,count=0;
int game,instruct;
char tmp_str[40];
void display2();
void displost();
void init(void)
GLfloat mat_ambient[]={0.0,0.0,0.0,1.0};
glShadeModel (GL_SMOOTH);
glColorMaterial(GL_FRONT_AND_BACK,
GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_COLOR_MATERIAL);
glPushMatrix();
glScalef(0.3,0.2,0.15);
glTranslatef(x,y,0);
while (*message)
glutStrokeCharacter(GLUT_STROKE_ROMAN,*message++);
glPopMatrix();
void myHit()
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,200,0,200);
glMatrixMode(GL_MODELVIEW);
glClearColor(1.0,0.0,0.5,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("WINNER!!",70,550);
int j;
glPushMatrix();
glScalef(0.1,0.1,0.0);
glTranslatef(x,y,0);
while (*message)
glutStrokeCharacter(GLUT_STROKE_ROMAN,*message++);
for(j=0;j<10000;j++);
glPopMatrix();
void instructions()
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,200,0,200);
glMatrixMode(GL_MODELVIEW);
glClearColor(1.0,0.7,0.0,1.0);
glColor3f(1.0,0.5,0.1);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
glLineWidth(4.0);
draw_instruct("Instructions",600,1850); // change1
draw_instruct("to play",300,1500);
draw_instruct("Press f to shoot",300,1300);
glFlush();
glScalef(0.02,0.02,0.0);
while(*string)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,
*string++);
void display1()
{
int i;
if(counter1==3)
display2();
glFlush();
else
{ int j;
for(j=0;j<10000;j++);
glClearColor(1.0,0.7,0.0,1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glColor3f(1, 1, 0);
glRasterPos2f(-0.9, 0.9);
Write(tmp_str);
glPopMatrix();
if(count>=30)
glutDisplayFunc(displost);
glPushMatrix();
glColor3f(1, 1, 0);
glRasterPos2f(-0.2, 0.9);
Write(tmp_str);
glPopMatrix();
glPushMatrix();
glColor3f(1.0,0.0,0.0);
glLoadIdentity();
glTranslatef(0.8,-0.869+up,0.0);
glutSolidSphere(0.15,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)
//collision detection
{
counter1 ++;
for(j=0;j<10000;j++);
shoot=0;
pos=-0.2;
bang=1;
if(counter1==3)
count=0;
up=(up+0.005);
if(up>2)
up=0;
if(shoot==1)
pos=pos+0.009;
if(pos>2)
pos=-0.2;
shoot=0;
}
glutPostRedisplay();
glFlush();
void display2()
{int i;
if(counter2==3)
{ myHit();
glFlush();
else
{int j;
for(j=0;j<10000;j++);
glClearColor(1.0,0.7,0.0,1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glPushMatrix();
glColor3f(1, 1, 0);
glRasterPos2f(-0.9, 0.9);
glPopMatrix();
if(count>=20)
glutDisplayFunc(displost);
glPushMatrix();
glColor3f(1, 1, 0);
glRasterPos2f(-0.2, 0.9);
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)
counter2 ++;
for(j=0;j<10000;j++);
shoot=0;
pos=-0.2;
bang=1;
up=(up+0.005);
if(up>2)
up=0;
if(shoot==1)
pos=pos+0.009;
if(pos>2)
pos=-0.2;
shoot=0;
glutPostRedisplay();
glFlush();
void display()
glClearColor(1.0,0.7,0.0,1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glFlush()
}
void displost()
{
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,200,0,200);
glMatrixMode(GL_MODELVIEW);
glClearColor(1.0,0.0,0.5,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!!",70,550);
glFlush();
}
void indisplay()
{
glClearColor(1.0,0.7,0.0,1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
instructions();
glFlush();
}
void keyboard(unsigned char key,int x,int y)
{
if (key=='f')
{
shoot=1;
count++;
}
}
void choose(int i)
{
switch(i)
{ case 1: exit(0);
case 2: glutDisplayFunc(display1);
break;
case 3: glutDisplayFunc(display2);
break;
default:exit(0);
}
}
int main(int argc,char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DEPTH|GLUT_RGB);
glutInitWindowSize(1500,1500);
glutInitWindowPosition(0,0);
instruct=glutCreateWindow("Instructions");
init();
glutDisplayFunc(indisplay);
glutInitDisplayMode(GLUT_DEPTH|GLUT_RGB);
glutInitWindowSize(1000,1000);
glutInitWindowPosition(0,0);
game=glutCreateWindow("Proj");
init();
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutCreateMenu(choose);
glutAddMenuEntry("Quit",1);
glutAddMenuEntry("PlayLevel1",2);
glutAddMenuEntry("PlayLevel2",3);
glutAttachMenu(GLUT_RIGHT_BUTTON);
glutMainLoop();
return 0;
}
CHAPTER 8
CONCLUSION
Our project "Bullz Eye" encompasses a broad range of OpenGL functionalities. We have made of
concepts learnt in theory including 3Drepresentation, 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.
Future Scope
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] AlFuqaha, 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
REFERENCES
[1] https://studentprojectguide.com/project-report/synopsis/online-ticket-booking
System.
[2] https://www.scribd.com/document/407263913/EVENT-TICKET-BOOKING
SYSTEM-docx.
[3] Android Developer Fundamentals Course – Concepts.
[4] Erik Hellman, “Android Programming – Pushing the Limits”, 1st Edition,
Wiley India Pvt Ltd,2014.
[5] Dawn Griffiths and David Griffiths, “Head First Android Development”, 1st
Edition, O’Reilly SPD Publishers, 2015.
[6] Bill Phillips, Chris Stewart and Kristin Marsicano, “Android Programming: The