0% found this document useful (0 votes)
32 views22 pages

CG Project Report

Uploaded by

vikasve.raj05
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)
32 views22 pages

CG Project Report

Uploaded by

vikasve.raj05
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/ 22

HELICOPTER GAME

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

JnanaSangam, Belagavi-590018

A Mini-Project report
ON
“HELICOPTER GAME”

BY

SANGEETH SIVAN 4MT19CS134

SAYOOJYA 4MT19CS139

UNDER THE GUIDANCE OF


Mrs.JEEVITHA SAMPATH Ms.AISHWARYA M BHAT
Asst. Professor Asst. Professor
Dept. of CSE Dept. of CSE

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING


(NBA Accredited)
MANGALORE INSTITUTE OF TECHNOLOGY & ENGINEERING
(An ISO 9001:2015 Certified Institution)
BADAGA MIJAR, MOODBIDRI
D.K DIST-574225

1 CSE Department
HELICOPTER GAME

MANGALORE INSTITUTE OF TECHNOLOGY & ENGINEERING


(An ISO 9001:2015 Certified Institution)

BADAGA MIJAR, MOODABIDRI, D.K DIST.-574225

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING


(NBA Accredited)

CERTIFICATE
This is to certify that the mini project entitled “HELICOPTER GAME” is a bonafide work carried
out by SANGEETH SIVAN bearing USN 4MT19CS134 and SAYOOJYA bearing USN
4MT19CS139 in partial fulfillment of the requirements for the Computer Graphics and
Visualization Laboratory (18CSL68) as per Visvesvaraya Technology University, Belagavi
during the year 2021-22. It is certified that all corrections or suggestions indicated for internal
assessment have been incorporated in the report and has been verified and validated.

................................... .................................................
Signature of the Guides Signature of the HOD
Mrs.JEEVITHA SAMPATH Mr. RAVI NARAYANAN B
Ms.AISHWARYA M BHAT

Examiners Signature with date

1. .............................. ...............................

2. .............................. ...............................

2 CSE Department
HELICOPTER GAME

ACKNOWLEDGMENT
We express our gratitude to our institution and management for providing us with good
infrastructure, laboratory facilities, qualified and inspiring staff, whose guidance was immense help
in completion of project successfully.

We are extremely thankful to our dignified principle Dr. G.L. Easwara Prasad for his support and
encouragement.

We thank Mr.Ravi Narayana B, professor & HOD, Department of Computer Science and
Engineering for encouragement and favour.

We would like to thank Mrs.JEEVITHA SAMPATH and Ms.AISHWARYA M BHAT, project


guide, who meticulously went away beyond the call of duty in regarding numerous detailed
comments on technical matters and inspiring and elucidating guidance at all stages of development of
this project.

We would also like to express our deep gratitude to all lectures and lab staffs for their vital and timely
help that have made our project a success.

We would also like to thank our friends who have contributed in all possible ways in completing this
project successfully.

Naturally we take full responsibility for any lack of clarity, occasional erratum or inexactness that may
occur.

SANGEETH SIVAN SAYOOJYA

(4MT19CS134) (4MT19CS139)

3 CSE Department
HELICOPTER GAME

i
ABSTRACT
The proposed project is simple Helicopter game, which mainly demonstrates the simple application
of Opengl in gaming applications. The idea behind the game is to navigate the helicopter by avoiding
obstacles and avoiding hitting the roof of the cave or the floor. Initially one needs to press the left
mouse button to make the helicopter move upwards, once released helicopter goes down, the gamer
has to concentrate on left button to skip the obstacles. The goal is to go as far as possible so that the
score can be increased.

ii

4 CSE Department
HELICOPTER GAME

TABLE OF CONTENTS
ABSTARCT i
ACKNOWLEDGMENT ii
LIST OF SNAPSHOTS iii

CHAPTER NO TITLE PAGE NO.


1 INTRODUCTION 1
1.1 Computer Graphics 1
1.2 OpenGL 2
2 REQUIREMENT ANALYSIS 3
2.1 Non-functional Requirement 3
2.2 Functional Requirement 3
2.2.1 HardwareRequirement 4
2.2.2 System Requirement 4
3 DESIGN 5
3.1 Description 5
3.2 Algorithm 5
3.3 Flowchart 6
4 IMPLEMENTATION 7
4.1 Overview 7
4.2 Code Snippets 7
4.2.1 User-defined-Functions 7
4.2.2 Built-In-Functions 39
5 RESULTS 41
6 CONCLUSION AND FUTURE ENHANCEMENT 44
6.1 Conclusion 44
6.2 Future enhancement 44
REFERENCES 45

5 CSE Department
HELICOPTER GAME

LIST OF SNAPSHOT

PAGE NO. SNAPSHOT LABEL

41 Snapshot 5.1 : Introduction page

42 Snapshot 5.2 : scene 1 showing railway staion

43 Snapshot 5.3 : scene 2 showing arrival of the train 43

Snapshot 5.4 : scene 2 showing train has been

stopped at the railway station

44 Snapshot 5.5 : scene 3 showing departure of the

train

iii

6 CSE Department
HELICOPTER GAME

CHAPTER 1
INTRODUCTION
1.1 Computer Graphics
The term computer graphics has been used in a broad sense to describe "almost everything on
computers that is not text or sound". Typically, the term computer graphics refers to several
different things:

• the representation and manipulation of image data by a computer


• the various technologies used to create and manipulate images
• the sub-field of computer science which studies methods for digitally synthesizing and
manipulating visual content, see study of computer graphics

Today, computer graphics is widespread. Such imagery is found in and on television,


newspapers, weather reports, and in a variety of medical investigations and surgical procedures.
A well-constructed graph can present complex statistics in a form that is easier to understand
and interpret. In the media "such graphs are used to illustrate papers, reports, theses", and other
presentation material.

Many tools have been developed to visualize data. Computer generated imagery can be
categorized into several different types: two dimensional (2D), three dimensional (3D), and
animated graphics. As technology has improved, 3D computer graphics have become more
common, but 2D computer graphics are still widely used. Computer graphics has emerged as a
sub-field of computer science which studies methods for digitally synthesizing and
manipulating visual content. Over the past decade, other specialized fields have been developed
like information visualization, and scientific visualization more concerned with "the
visualization of three dimensional phenomena (architectural, meteorological, medical,
biological, etc.), where the emphasis is on realistic renderings of volumes, surfaces,
illumination sources, and so forth, perhaps with a dynamic (time) component"[4].

7 CSE Department
HELICOPTER GAME

1.2 OpenGL
OpenGL (Open Graphics Library) is a cross-platform, hardware-accelerated, language
independent, industrial standard API for producing 3D (including 2D) graphics. The OpenGL
specification describes an abstract API for drawing 2D and 3D graphics. OpenGL is the
standard application program interface (API) for defining 2-D and 3-D graphic images. Prior to
OpenGL, any company developing a graphical application typically had to rewrite the graphics
part of it for each operating system platform and had to be cognizant of the graphics hardware
as well. With OpenGL, an application can create the same effects in any operating system using

any OpenGL-adhering graphics adapter.

OpenGL specifies a set of "commands" or immediately executed functions. Each command


directs a drawing action or causes special effects. A list of these commands can be created for
repetitive effects. OpenGL is independent of the windowing characteristics of each operating
system, but provides special "glue" routines for each operating system that enable OpenGL to
work in that system's windowing environment. OpenGL comes with a large number of built-in
capabilities requestable through the API. These include hidden surface removal, alpha blending
(transparency), antialiasing , texture mapping, pixel operations, viewing and modelling
transformations, and atmospheric effects (fog, smoke, and haze).

Although the function definitions are superficially similar to those of the programming
language C, they are language-independent. In addition to being language-independent,
OpenGL is also cross-platform. The specification says nothing on the subject of obtaining, and
managing an OpenGL context, leaving this as a detail of the underlying windowing system. For
the same reason, OpenGL is purely concerned with rendering, providing no APIs related to
input, audio, or windowing. In addition to the features required by the core API, graphics
processing unit (GPU) vendors may provide additional functionality in the form of extensions.
Extensions may introduce new functions and new constants, and may relax or remove
restrictions on existing OpenGL functions. All extensions are collected in, and defined by, the
OpenGL Registry [1].

Summary: This chapter gives an overview of computer graphics.

8 CSE Department
HELICOPTER GAME

CHAPTER 2

REQUIREMENT ANALYSIS
2.1 Non-Functional Requirements
In systems engineering and requirements engineering, a non-functional
requirement (NFR) is a requirement that specifies criteria that can be used to
judge the operation of a system, rather than specific behaviours. They are
contrasted with functional requirements that define specific behaviour or

functions. Some of the functional requirements for the train are


Performance-for example :response time, throughput, utilization, static

volumetric.


Scalability


Capacity


Availability


Reliability


Recoverability


Maintainability


Serviceability

9 CSE Department
HELICOPTER GAME

2.2 Functional Requirements


The functional requirements are the requirements which are needed to develop
the software application. The functional requirement are broadly classified into
2 categories, they are,

1. Hardware Requirements

2. Software Requirements

2.2.1 Hardware Requirements

For the hardware requirements the SRS(Software requirement


specificaion) specifies the logical characteristics of each interface between the
software product and the hardware components.It specifies the hardware
requirements like memory restrictions,cache size,the processor,RAM size
etc..those are required for the software to run.

• Processor : Intel i3/i5/i7


• Processor speed : 1GB or more
• Hard disk : 40GB or more
• RAM size : 1GB or more
• Display : 800x600 or higher resolution
display with 256 colours.
• Mouse : Standard serial mouse
• Keyboard : Standard QWERTY Keyboard
• GPU : Intel HD Graphics 5000 or better

2.2.2 Software Requirement

• Operaring System : Windows 10,64 bits


• Software used : Dev- C++
• Programming language : C language
• Graphics Library : GL and GLU/GLUT
• Compiler used : MinGW Compiler

10 CSE Department
HELICOPTER GAME

CHAPTER 3
DESIGN
3.1 Description
Train arrival and departure is a newly designed computer graphics mini project.In this
mini project,there will be objects like train,signal, and a place called “railway station.In our
mini project,the second scene describes about the arrival of the train.Here when you press up
arrow key it increases the speed of the train and when you press down arrow key, it decreases
the speed of the train and finally it stops.In the third scene we have shown the departure of the
train.Here the train is in the railway station and starts to depart from the station.When you press
right arrow key it increases the speed of the train and when you press the down arrow key it
decreases the speed of the train.We should press r or R to move from first scene to second
scene and press a or A to move from second scene to third scene.

3.2 Algorithm
An algorithm is a step-by-step instruction to execute the program. The algorithm of our project is
shown below.

11 CSE Department
HELICOPTER GAME

Step 1: Initialize the graphics library.


Step 2: Display the starting page.
Step 3: Take the user input.
If input =
ENTER Scene
1() end if
Step 4: Press r for the scene 2.
If input = r
Scene 2()
Step 5: Press a for the scene 3.
If input = a
Scene 3()
end if

12 CSE Department
HELICOPTER GAME

3. Flowchart

start

Content page

Press ENTER

(down arrow
Scene 1(railway Key)
station)
Decreases the
Press r speed of the
train

Scene 2(Arrival of if Increases the


train speed of the
(up arrow train

Press a key)

Scene 3(Departure if
of train) Increases the
speed of the
(right arrrow

key)
Decreases the
speed of the
train
Stop
(left arrow key)

13 CSE Department
HELICOPTER GAME

Chapter 4
IMPLEMENTATION
4.1 Overview
Implementation is the carrying out, execution, or practice of a plan, a method, or any design for
doing something. As such, implementation is the action that must follow any preliminary
thinking in order for something to actually happen. In an information technology context,
implementation encompasses all the processes involved in getting new software or hardware
operating properly in its environment, including installation, configuration, running, testing,
and making necessary changes. The word deployment is sometimes used to mean the same
thing. This project has been developed using OpenGL provided by Visual C++.

4.2 Code snippets


4.2.1 User defined Functions

Code Snippet-1
The following code is used to present the first slide and the simulation of the helicopter

Code Snippet-2 :

The following code is used for drawing the helicopter


void drawcopter()
{
glBegin(GL_POLYGON);
glColor3f(0.8,1,0);
glVertex2f(10,49.8);
glVertex2f(19.8,49.8);
glVertex2f(25,47.3);
glVertex2f(19.8,42.8);
glVertex2f(10,42.8);
glVertex2f(10,47.3);
glColor3f(0.7,1.0,1.0);
glEnd();
//glRectf(10,49.8,19.8,44.8);//body
glColor3f(1,0,0.1);
glRectf(2,46,10,48);//tail
glColor3f(1,0,0.1);
glRectf(2,46,4,51);//tail up
glColor3f(1,0,0.1);
glRectf(14,49.8,15.8,52.2);//propeller stand
glColor3f(1,0,0.1);
glRectf(7,53.6,22.8,52.2);//propeller*/
}

14 CSE Department
glColor3f(1.0,0.0,0.0);
renderBitmapString(40,70,0,GLUT_BITMAP_HELVETICA_18,"GAME OVER!!!");
glColor3f(1.0,1.0,1.0);

HELICOPTER GAME
renderBitmapString(25,58,0,GLUT_BITMAP_TIMES_ROMAN_24,"You");
renderBitmapString(45,58,0,GLUT_BITMAP_TIMES_ROMAN_24,"scored:");
renderBitmapString(70,58,0,GLUT_BITMAP_TIMES_ROMAN_24,scs);
glutSwapBuffers();
glFlush();
printf("\nGAME OVER\n\n");
printf("%s You scored %s" ,name,scs);
printf("\n\nClose the console window to exit...\n");
Sleep(80);
exit(0);
}else if(wflag==1)//Welcome Screen
{
wflag=0;
glBegin(GL_POLYGON);
glColor3f(1.0,1.0,1.0);
glVertex2f(0.0,100.0);
glColor3f(0.8,0.0,0.4);
glVertex2f(0.0,90.0);
glColor3f(1.0,1.0,0.4);
glVertex2f(100.0,100.0);
glColor3f(0.5,0.1,1.0);
glVertex2f(100.0,90.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0,1.0,1.0);
glVertex2f(0.0,0.0);
glColor3f(0.8,0.0,0.4);
glVertex2f(100.0,0.0);
glColor3f(1.0,1.0,0.4);
glVertex2f(100.0,10.0);
glColor3f(0.5,0.1,1.0);
glVertex2f(0.0,10.0);
glEnd();
glColor3f(1.0,1.0,1.0);
renderBitmapString(16,85,0,GLUT_BITMAP_HELVETICA_18,"MANGALORE INSTITUTE OF TECHNOLOGY &
ENGINEERING");
glColor3f(0.8,0.0,0.3);
renderBitmapString(39,75,0,GLUT_BITMAP_HELVETICA_18,"DEPARTMENT OF CSE");
glColor3f(0.7,0.5,1.0);
renderBitmapString(20,65,0,GLUT_BITMAP_8_BY_13,"Mini Project in Computer Graphics & Visualization Laboratory");
glColor3f(1.0,1.0,1.0);
renderBitmapString(40.5,70,0,GLUT_BITMAP_TIMES_ROMAN_24,"Helicopter Game");
renderBitmapString(35.5,60,0,GLUT_BITMAP_TIMES_ROMAN_24,"By Sangeeth Sivan & Sayoojya");
glColor3f(0.6,0.0,0.1);
renderBitmapString(40,45,0,GLUT_BITMAP_TIMES_ROMAN_24,"Welcome");
renderBitmapString(53,45,0,GLUT_BITMAP_TIMES_ROMAN_24,name);
renderBitmapString(43,30,0,GLUT_BITMAP_TIMES_ROMAN_24,"Click To Start");
glColor3f(0.6,0.5,1.0);
renderBitmapString(17,24,0,GLUT_BITMAP_9_BY_15,"CLICK AND HOLD LEFT MOUSE BUTTON TO GO UP RELEASE TO
GO DOWN");
glColor3f(0.0,0.0,0.0);
drawcopter();
glutSwapBuffers();
glFlush();
}else
{
if(sci%50==0&&lflag==1)
{
lflag=0; //make level_flag=0
level++;//increase level by 1
bspd+=0.001;//increase block_dx_speed by 0.01
}
else if(sci%50!=0&&lflag!=1)
{
lflag=1;
}
glPushMatrix();
glColor3f(1,1,0.1);
glRectf(0.0,0.0,100.0,10.0); //ceil
glColor3f(1,0.7,1);
glRectf(0.0,100.0,100.0,90.0); //floor
glColor3f(0.0,0.0,0.0); //score
renderBitmapString(1,3,0,GLUT_BITMAP_TIMES_ROMAN_24,"Distance:");
sprintf(slevel,"%d",level); //level
renderBitmapString(80,3,0,GLUT_BITMAP_TIMES_ROMAN_24,"Level:");
renderBitmapString(93,3,0,GLUT_BITMAP_TIMES_ROMAN_24,slevel);
scf+=0.025; //so less as program run very fast
sci=(int)scf;
sprintf(scs,"%d",sci);
renderBitmapString(20,3,0,GLUT_BITMAP_TIMES_ROMAN_24,scs);
glTranslatef(0.0,hm,0.0);
drawcopter();
if(b1x<-10)
{ 15 CSE Department
b1x=50; //total width is 50
b1y=(rand()%25)+20;
HELICOPTER GAME

4.2.1 Built –in- Functions

 void glColor3f(GLfloat red, GLfloat green, GLfloat blue): This function sets present RGB
colours. Different colour is given to object using the colours parameters such as red, green,
blue. The maximum and minimum values of the floating point types are 1.0 and 0.0

respectively.

 void gluOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,


GLdouble near, GLdouble far ): Defines the orthographic volume with all the parameters
measured from the centre of projection of the plane.
 voidglLineWidth(width): Line width is set in OpenGL with

function glLineWidth(width). Floating point value is assigned to parameters width, and


this value is rounded to nearest non-negative integer.

 voidLoadIdentity(): Sets the current transformation matrix to an identity matrix.

 voidglClear(GL_COLOR_BUFFER_BIT): Clears all buffer whose bits are set in mask.


The mask is formed by the logical OR of values defined in gl.h
GL_COLOR_BUFFER_BIT refers to colour buffers.
 voidglBegin( ) and void glEnd( ): The glBegin and glEnd functions delimit the vertices of a
primitive or a group of like primitives. Syntax of glBegin is as follows: glBegin(GLenum
mode);
 voidglFlush(void): The glFlush function forces execution of OpenGL function in finite
time. This function has no parameters. This function does not return a value.

16 CSE Department
HELICOPTER GAME

 voidMatrixMode(GL_PROJECTION): Projection matrixes are stored inOpenGL projection


mode. So to set the projection transformation matrix. That mode is invoked through the
statement, glMatrixMode(GL_PROJECTION)
 voidglutDisplayFunc(): Sets the display call back for the current window.

 voidglEnable(GLenum cap): Enables server side GL capability.

 voidglDepthFunc(GLenumfunc): Specifies the values used for depth buffer comparison.

 voidglutPostRedisplay(): Mark the normal plane of current window as needing to be


redisplayed. The next iteration through glutMainLoop, the window’s display call back will
be called to redisplay the window’s normal plane. Multiple calls to glutPostRedisplay
before the next display call back opportunity generates only a single redisplay call back.
GlutPostRedisplay may be called within a window’s display or over lay display call back to
remark that windows for redisplay.
 voidglutInit(int *argc, char **argv): The glutInit will initialize the GLUT library, the
arguments form main are passed in and can used by the application. This will negotiate a
session with the window system. During this process, glutInit may cause the termination of
the GLUT program with an error message to user if GLUT cannot be properly initialized.
 voidglutInitDisplayMode(unsigned int mode): The glutInitDisplayMode sets the initial
display mode. It requests a display with the properties in mode. The value of mode is
determined by the logical OR of option including the colour model(GLUT_RGB),
buffering (GLUT_DOUBLE) and (GLUT_DEPTH).
 voidglutInitWindowSize(int width, int height): This function specifies the initial height and

width of the width in pixels.

 voidglutInitWindowPosition(int x, int y): This function specifies the initial position of the

top-left corner of the windows in pixels.

 voidglutCreateWindow(char *title): The glutCreateWindow create a window on the


display. The string title can be used to label the window. The return value provides a
reference to the window that can be used when there are multiple windows.
 voidglutMainLoop(): Cause the program to enter an event-processing loop. It should be the
last statement in the main.

 voidmyinit(void ): Sets the background colour and viewing

17 CSE Department
HELICOPTER GAME

Chapter 5
RESULTS AND SNAPSHOTS

18 CSE Department
HELICOPTER GAME

5.1 Snapshot-1

Referring to the figure 5.1 it shows the initial view of our project.

19 CSE Department
HELICOPTER GAME

5.2 Snapshot-2

Referring to the figure 5.2 it refers to the first scene which shows railway station

5.3 Snapshot-3
Referring to the figure 5.3 it refers to the second scene which shows arrival of the train to the
railway station

20 CSE Department
HELICOPTER GAME

Chapter 6
CONCLUSION AND FUTURE ENHANCEMENT
6.1 Conclusion
This project demonstraest the working of arrival and departure of the train using computer
graphics and different functions of OpenGL. This project mainly tries to give an idea of how the
railway station look like so that we can use his graphics in some animated stories or use to
demonstrate to the small children. The overall implementation of the code is done in Dev-C++
and the programming language used is OpenGL which is mainly used to design the computer
graphics project.

6.2 Future Enhancement


This project shows certain simulation process which is based on moving train. A better
visualization can be given using OpenGL graphics library. The proposedproject uses OpenGL’s
graphic functions in 2D. As an improvement one can make use of some 3D effect . Compact and
sophisticated code can be used.

21 CSE Department
HELICOPTER GAME

REFERENCES

Text book : Donald D. Hearn

M.Pauline Baker

Warren Carithers

Reference link: https://youtu.be/DjnPrJRdvPY

22 CSE Department

You might also like