Car Model

Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

Mini Project Report 2023-2024

CHAPTER 1
INTRODUCTION
Computer Graphics is one of the most powerful and interesting facets of computers.
There is a lot we can do in graphics apart from drawing figures of various shapes. All video
games, animation, multimedia predominantly works using computer graphics. There are so
many applications of computer graphics, which make it significant. Computer graphics is
concerned with all aspects of producing pictures or images using a computer.

1.1 Overview of Project


A car is a useful means of transportation from one place to another place.
Development in the field of science and technology led to the discovery of car which helped
the mankind in various ways. Since many years the automobiles have been subjected to
continuous evolution and hence a variety of car models with each one having its own
features, shape and size exist today. This is an approach to simulate the working of one such
model of a car.
The car used here is a 3D object with simple features. One can either view the car
model or enter into the driving mode. In the former case, the car is placed against a plain
background whereas in the latter case, it is placed on a road having greenery in the
background. The car can be moved to and forth, rotated about the three principle axes and
can be changed in terms of size and color. Along with the above features the fog and wheel
effects can also be imposed on the car. The car can be viewed either in the day mode or in
the night mode. A uniform lighting effect is also included, however it is left to the user to
enable or disable lighting. Also, the car can be zoomed in or zoomed out. All these actions
can be performed by using the menu provided

1.2 Problem Statement


The problem is mainly concerned with modeling a car and highlighting some of the
common features of a car. The car is subjected to many openGL transformations to bring
out unique effects on the car.

Dept of CSE Page 1


Mini Project Report 2023-2024

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


120 distinct commands, which we use to specify the objects and operations needed to
produce interactive 3 dimensional applications.

OpenGL has become a widely accepted standard for developing graphics applications.
It can be used to implement several effects. Hence this project has become more colorful
because of the effects implemented using openGL.

Dept of CSE Page 2


Mini Project Report 2023-2024

CHAPTER 2
INTRODUCTION ABOUT OPENGL
OpenGL is a software interface to graphics hardware. This interface consists of
about 150 distinct commands that is used to specify the objects and operations needed to
produce interactive three-dimensional applications.

OpenGL (Open Graphics Library) : is a standard specification defining a cross-language,


cross-platform API for writing applications that produce 2D and 3D computer graphics the
interface consists of over 250 different function calls which can be used to draw complex
three-dimensional scenes from simple primitives. OpenGL was developed by Silicon
Graphics Inc. (SGI) in 1992 and is widely used in CAD, virtual reality, scientific
visualization, information visualization, and flight simulation.

OpenGL is designed as a streamlined, hardware-independent interface to be


implemented on many different hardware platforms. To achieve these qualities, no
commands for performing windowing tasks or obtaining user input are included in
OpenGL; instead, user must work through whatever windowing system controls the
particular hardware that the user is using.
OpenGL doesn't provide high-level commands for describing models of three- dimensional
objects. A sophisticated library that provides these features could certainly be built on top
of OpenGL. The OpenGL Utility Library (GLU) provides many of the modeling features.
OpenGL serves two main purposes:

• To hide the complexities of interfacing with different 3D accelerators, by presenting


the programmer with a single, uniform API.

• To hide the differing capabilities of hardware platforms, by requiring that all


implementations support the full OpenGL feature set (using software emulation if
necessary).
OpenGL's basic operation is to accept primitives such as points, lines, polygons, and
convert them into pixels. This is done by a graphics pipeline known as the OpenGL state
machine.

Dept of CSE Page 3


Mini Project Report 2023-2024

The color plate gives an idea of the kinds of things that can be done with the OpenGL
graphics system. The following list briefly describes the major graphics operations which
OpenGL performs to render an image on the screen.
• Construct shapes from geometric primitives, thereby creating mathematical
descriptions of objects. (OpenGL considers points, lines, polygons, images, and
bitmaps to be primitives.)

• Arrange the objects in three-dimensional space and select the desired vantage point
for viewing the composed scene.

• Calculate the color of all the objects. The color might be explicitly assigned by the
application, determined from specified lighting conditions, obtained by pasting a
texture onto the objects, or some combination of these three actions.

• Convert the mathematical description of objects and their associated color


information to pixels on the screen. This process is called rasterization.

2.1 OpenGL Command Syntax
OpenGL commands use the prefix gland initial capital letters for each word making
up the command name (recall glClearColor(), for example).
OpenGL defined constants begin with GL_, use all capital letters, and use underscores to
separate words (like GL_COLOR_BUFFER_BIT).The user might also have noticed some
seemingly extraneous letters appended to some command names (for example, the 3f in
glColor3f () and glVertex3f (). It's true that the Color part of the command name glColor3f
() is enough to define the command as one that sets the current color.

2.2 OpenGL as a State Machine


OpenGL is a state machine. It can be put into various states (or modes) that then
remain in effect until it is changed. The user can set the current color to white, red, or any
other color, and thereafter every object is drawn with that color until the current set color to
something else. Others control such things as the current viewing and projection
transformations, line and polygon stipple patterns, polygon drawing modes, pixel-packing
conventions, positions and characteristics of lights, and material properties of the objects
being drawn. Many state variables refer to modes that are enabled or disabled with the

Dept of CSE Page 4


Mini Project Report 2023-2024

command glEnable () or glDisable (). Each state variable or mode has a default value, and
at any point the user can query the system for each variable's current value.

2.3 OpenGL Rendering Pipeline

Figure 1.1: Order of Operations

Most implementations of OpenGL have a similar order of operations, a series of processing


stages called the OpenGL rendering pipeline. Given below are the key stages in the OpenGL
rendering pipeline.

Display Lists

All data, whether it describes geometry or pixels, can be saved in a display list for
current or later use. When a display list is executed, the retained data is sent from the display
list just as if it were sent by the application in immediate mode.

Evaluators

All geometric primitives are eventually described by vertices. Parametric curves and
surfaces may be initially described by control points and polynomial functions called basis
functions. Evaluators provide a method to derive the vertices used to represent the surface
from the control points.

Per-Vertex Operations

For vertex data, next is the "per-vertex operations" stage, which converts the vertices
into primitives. Some vertex data are transformed by 4 x 4 floating-point matrices. Spatial
coordinates are projected from a position in the 3D world to a position on the screen.

Dept of CSE Page 5


Mini Project Report 2023-2024

Primitive Assembly
Clipping, a major part of primitive assembly, is the elimination of portions of
geometry which fall outside a half-space, defined by a plane. Point clipping simply passes
or rejects vertices; line or polygon clipping can add additional vertices depending upon how
the line or polygon is clipped. The results of this stage are complete geometric primitives,
which are the transformed and clipped vertices with related color, depth, and sometimes
textureco-ordinate values and guidelines for the rasterization step.

2.4 OpenGL - Related Libraries


OpenGL provides a powerful but primitive set of rendering commands, and all
higherlevel drawing must be done in terms of these commands. Also, OpenGL programs
have to use the underlying mechanisms of the windowing system. A number of libraries
exist to allow the user to simplify the programming tasks, including the following:
The OpenGL Utility Toolkit (GLUT) is a programming interface with ANSI C and
FORTRAN bindings for writing window system independent OpenGL programs. The
toolkit supports the following functionality:

• Multiple windows for OpenGL rendering.

• Callback driven event processing.

• Sophisticated input devices.

• An “idle” routine and timers.

• A simple, cascading pop-up menu facility.

• Utility routines to generate various solid and wire frame objects.

• Support for bitmap and stroke fonts.

• Miscellaneous window management functions, including managing overlays.

Dept of CSE Page 6


Mini Project Report 2023-2024

CHAPTER 3

REQUIREMENT SPECIFICATIONS

A requirements specification is a description of a software system to be developed,


laying out functional and non-functional requirements, and may include a set of use cases
that describe interactions the users will have with the software.

3.1 Requirements of the project


A graphics package that attracts the attention of the viewers is to be implemented.
The package should provide a platform for user to perform animation.

3.2 Resource Requirements


The requirement analysis phase of the project can be classified into:

• Hardware Requirements

• Software Requirements

• Functional Requirements

• Non-Functional Requirements

3.2.1 Software Requirements


This document will outline the software design and specification of our application.
The application is a Windows based .Net implementation with OpenGL. Our main UI will
be developed in C#, which is a .Net language. This application will allow viewing of GDS
II files, assignment of Color and Transparency to layers within the VLSI object, as well as
printing of the rendered object. There will be the ability to save these color/transparency
palettes for a given GDS file as well as the foundry used to create the file. These palettes
can then be used with future GDS files to save time assigning colors/transparencies to
layers.

Dept Of CSE Page 7


Mini Project Report 2023-2024

Characteristics required of the interface between the software product and each of the
hardware components
Any mouse and keyboard that works with Win Forms

Program will use windows print APIs to interface with printer.Interface with other
software components or products, including other systems, utility software, databases, and
operating systems.
OpenGL libraries for required are

• GLUT library

• STDLIB library

The application is very self-contained. Robust error handling will be implemented and
code will be object-oriented to allow for easier maintenance and feature additions.
This model runs using Microsoft Visual Studio version 2010 on a Windows XP platform.

3.2.2 Hardware Requirements


There are no rigorous restrictions on the machine configuration. The model should be
capable of working on all machines capable of supporting recent versions of Microsoft
Visual Studio.

• Processor: Intel® Pentium 4 CPU

• Hard disk Capacity: 80 GB

• RAM: 1 GB

• CPU Speed: 2.9 GHz

• Keyboard: Standard

• Mouse: Standard

Dept of CSE Page 8


Mini Project Report 2023-2024

Visual Studio Hardware Requirements

Some specific hardware requirements are needed for Visual Studio 2010 .They can be listed
as:
Requirement Professional

Processor 1.6 GHz processor or higher

RAM 384 MB of RAM or more (768 MB of RAM or

more for Windows Vista)

Available Without MSDN:


Hard
• 2.2 GB of available space required
Disk Space
on system drive

With MSDN:

• 3.8 GB of available space required


on installation drive with a full installation of
MSDN

Operating Visual Studio 2010can be installed on the

System following operating system:

Windows® XP (x86 &x64) with Service Pack

2 or later all editions except Starter Edition

Windows Server 2003 R2 (x86 and x64)

Video 1024 X 768, High Color 16-bit

Mouse Microsoft mouse or compatible pointing device


Table 3.1: Hardware Requirements for Visual Studio 2010

Dept of CSE Page 9


Mini Project Report 2023-2024

• Performance has not been tuned for minimum system configuration. Increasing
the RAM above the recommended system configuration will improve
performance, specifically when there are running multiple applications,
working with large projects, or doing enterprise-level development.

3.2.3 Functional Requirements

These are the statements of services the system should provide, how the system should
react to particular inputs and how the system should behave in particular situations. In some
cases, the functional requirements may also explicitly state what the system should not do.

Dept of CSE Page 10


Mini Project Report 2023-2024

CHAPTER 4
DESIGN PHASE

Design of any software depends on the architecture of the machine on which that
software runs, for which the designer needs to know the system architecture. Design
process involves design of suitable algorithms, modules, subsystems, interfaces etc.
This project has been created using the OpenGL interface along with the GLUT(OpenGL
Library Tool), using the platform Visual C++ 6.0 as a compiling tool. This project 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.

4.1 Algorithm

Step 1: The execution of program starts from main ( ).

int main( argc, * argv[] )

Initialize GLUT state

Initialize Display Mode

Create and name the display window as “3D CAR SIMULATION “

Handle following functions using glut call back functions

DrawGLScene ( ) //Display call back

ResizeGLScene ( ) //Reshape call back

NormalKey ( ) //Keyboard call back

SpecialKeyFunc ( ) //Special Key board call back

Create_menu ( )

Start event processing loop.

Step 2: Create_menu ( )
Dept Of CSE Page 11
Mini Project Report 2023-2024

Create the submenu using glutCreateMenu(ColorMenu)

Each menu entry is created using glutAddMenuEntry ()


Create the Main menu using glutCreateMenu(myMenu) This menu helps to
select the mode of car and view effects.
Add submenu to the car colors entry in main menu.
Attach menu to the right mouse button using

glutAttachMenu (GLUT_RIGHT_BUTTON).

Step 3: The function called when window is resized.

ResizeGLscene ( )

Perform Transformations

Transform ( )

Step 4: Transformation Routine.

Transform ( )

Set the projection using glViewport ( )

Select the projection using glMatrixMode(GL_PROJECTION)

Reset the projection matrix

Calculate aspect ratio of window using gluPerspective ()

Switch back to the model view

Dept Of CSE Page 12


Mini Project Report 2023-2024

Step 5: The general OpenGL initialization function to set initial parameters.

InitGL( width, Height)

Set background color to white glClearColor(1.0,1.0,1.0,1.0)

Set line width glLineWidth (), Perform Transformations Transform ()

Enable lighting glEnable (GL_LIGHTING)

Set the ambient, diffuse, specular light at specific position using


glLightfv ()
}

Step 6: The display function to create the Help screen.

display1( )

Display_string(x , y, ”string”, font) x, y


specifies position of string to be displayed.
glutSwapBuffers( )

Display_string(x, y, string, font)

Set raster position using glRasterPos2f(x, y)


Set len to strlen(string) fori=0 to len
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_font,string[i])

Step 7: The main display function handled by display call back.

View=0 // to view help screen

Dept Of CSE Page 13


Mini Project Report 2023-2024

DrawGLScene ( )

if view is 0 then
display1( ) else
{ InitGL( )
Enable rotation by along the three axes using
glRotatef( xangle,1.0 ,0.0 ,0.0 )
glRotatef(yangle,0.0, 1.0, 0.0) glRotatef(zangle,
0.0, 0.0, 1.0)
Enable translation by calling glTranslatef (xt, yt, zt)

Enable scaling by calling glScalef(xs, ys, zs)

The car is drawn as 3d object

Body of car drawn specifying points using following function glBegin


(GL_QUADS)
//points defined as glVertex3f(x, y, z) glEnd
()
The wheels of car drawn using glutSolidTorous() if
car is in driving mode then
{

Draw green surroundings, long road, and median

glutSwapBuffers( );

} //end ofelse

} //end of DrawGLScene( )

Step 8: The action taken when a Normal key is pressed.


NormalKey (key, x, y)

Dept Of CSE Page 14


Mini Project Report 2023-2024

ifkey=ESCAPE then exit(0) if key=’ ‘ then view=1 if key=’x/X’ then


xangle++ /xangle-- respectively // Rotate about x axis if key=’y/Y’ then
yangle++/yangle-- respectively // Rotate about y axis if key=’z/Z’ then
zangle++/zangle-- respectively //Rotate about z axis if key=’u/U’
thenyt++/yt-- //move camera up and down respectively if key=’f/F’
thenzt++/zt++ //move camera forward and away respectively ifkey=’s/S’ then
zs++/zs-- //scale along z axis if key=’a/A’ thenys++/ys-- //scale along
y axis if key=’q/Q’ thenxs++/xs-- //scale along x axis
}//End of Normal key

Step 9: The action taken when a special key is pressed.

SpecialkeyFunc(key, x, y)

if key=GLUT_RIGHT_KEY then xt++ if


key=GLUT_LEFT_KEY thenxt- -
}

Step 10: The actions performed by each menu entry identified by id.

myMenu( id )

if id=’ car model mode’ then

{ Draw car against plain back ground }

ifid= ‘car driving mode’ then

{ Draw car against the road with greenery around } if


id=’fog effect’ then
{ Enable white color fog } if
id=’wheel effect ‘ then
{ Emphasize fast movement by adding mile stones along the road}

ifid=’ toggle ‘ then

{ Enable lighting effects }


if id=’day mode’ then

Dept Of CSE Page 15


Mini Project Report 2023-2024

{ Set back ground white } ifid=‘ night mode’


then {Enable black fog } }

4.2 Data flow Diagram


A flowchart is a common type of chart that represents an algorithm or process
showing the steps as boxes of various kinds, and their order by connecting these with
arrows. Flowcharts are used in analyzing, designing, documenting or managing a process
or program in various fields
Flowcharts used to be a popular means for describing computer algorithms. They
are still used for this purpose; modern techniques such as UML activity diagrams can be
considered to be extensions of the flowchart.
There are many different types of flowcharts. On the one hand there are different
types for different users, such as analysts, designers, engineers, managers, or programmers.
On the other hand those flowcharts can represent different types of objects.
Sterneckert (2003) divides four more general types of flowcharts:

• Document flowcharts, showing a document flow through system

• Data flowcharts, showing data flows in a system

• System flowcharts showing controls at a physical or resource level

• Program flowchart, showing the controls in a program within a system

Data flow diagrams show how data is processed at different stages in the system. Data
flow models are used to show how data flows through a sequence of processing steps. The
data is transformed at each step before moving on to the next stage. These processing steps
of transformations are program functions when data flow diagrams are used to document a
software design.
The use of space bar allows the user to enter into the display mode. The movement of
the car can be done using left and right arrow keys. The X/x, Y/y, Z/z keys are used
for corresponding rotation in clockwise or anti-clockwise direction. A/a, Q/q, S/s for
custom size collection.U/u, F/f for camera view settings. The escape key enables the
user to exit.

Dept Of CSE Page 16


Mini Project Report 2023-2024

The other effects can be viewed by selecting the appropriate menu. The menu can
be viewed by pressing the right mouse button. Menu callback is used to implement
these

Main ()
functions.

ChangeSize
RenderScene SetupRC
SpecialKeys

glViewport () GLUT_KEY_UP glPushMatrix () glClearColor

glPopMatrix () glLightfv ()
glMatrixMode() GLUT_KEY_DOW

glRotatef () glColorMateri
glLoadIdentity() GLUT_KEY_LEF
T glEnable al

GLUT_KEY_RIGH glBegin glMaterialfv


glOrtho ()
glutPostRedisplay () glBegin glMateriali()

glBegin glColor3f

Figure 3.2:Data flow Diagram.


The above Figure 3.2 shows the Data flow Diagram .The processing of different operations
in this project.

Dept Of CSE Page 17


Mini Project Report 2023-2024

CHAPTER 5
IMPLEMENTATION

5 : Functions implemented in project using opengl with code

#include <windows.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string>

5.1 Game Speed


int FPS = 50;
//Game Track
int start = 0;
int gv = 0;
int level = 0;

5.2 Track Score


const int font1 = (int)GLUT_BITMAP_TIMES_ROMAN_24;
const int font2 = (int)GLUT_BITMAP_HELVETICA_18;
const int font3 = (int)GLUT_BITMAP_8_BY_13;

char s[30];
void renderBitmapString(float x, float y, void *font, const char *string)
{
const char *c;
glRasterPos2f(x, y);
for (c = string; *c != '\0'; c++)

Dept Of CSE Page 18


Mini Project Report 2023-2024

{
glutBitmapCharacter(font, *c);
}
}

void tree(int x, int y)


{
int newx = x;
int newy = y;
//Bottom
glColor3f(0.871, 0.722, 0.529);
glBegin(GL_TRIANGLES);
glVertex2f(newx + 11, newy + 55);
glVertex2f(newx + 12, newy + 55 - 10);
glVertex2f(newx + 10, newy + 55 - 10);
glEnd();
//Top
glColor3f(0.133, 0.545, 0.133);
glBegin(GL_TRIANGLES);
glVertex2f(newx + 11, newy + 55 + 3);
glVertex2f(newx + 12 + 3, newy + 55 - 3);
glVertex2f(newx + 10 - 3, newy + 55 - 3);
glEnd();
}
5.3 Road
glColor3f(0.412, 0.412, 0.412);
glBegin(GL_POLYGON);
glVertex2f(20, 0);
glVertex2f(20, 100);
glVertex2f(80, 100);
glVertex2f(80, 0);
glEnd();

5.3.1 Road Left Border

Dept Of CSE Page 19


Mini Project Report 2023-2024

glColor3f(1.000, 1.000, 1.000);


glBegin(GL_POLYGON);
glVertex2f(20, 0);
glVertex2f(20, 100);
glVertex2f(23, 100);
glVertex2f(23, 0);
glEnd();

5.3.2 Road Right Border


glColor3f(1.000, 1.000, 1.000);
glBegin(GL_POLYGON);
glVertex2f(77, 0);
glVertex2f(77, 100);
glVertex2f(80, 100);
glVertex2f(80, 0);
glEnd() :
if (roadDivTop < -100)
{
roadDivTop = 20;
score++;
}
5.3.3 Middle Road
glColor3f(1.000, 1.000, 0.000);
glBegin(GL_POLYGON);
glVertex2f(48, roadDivMdl + 40);
glVertex2f(48, roadDivMdl + 60);
glVertex2f(52, roadDivMdl + 60);
glVertex2f(52, roadDivMdl + 40);
glEnd();
roadDivMdl = roadDivMdl - 0.5;
if (roadDivMdl < -60)
{
roadDivMdl = 60;
score++;
}

Dept Of CSE Page 20


Mini Project Report 2023-2024

5.3.4 Bottom
glColor3f(1.000, 1.000, 0.000);
glBegin(GL_POLYGON);
glVertex2f(48, roadDivBtm + 0);
glVertex2f(48, roadDivBtm + 20);
glVertex2f(52, roadDivBtm + 20);
glVertex2f(52, roadDivBtm + 0);
glEnd();
roadDivBtm = roadDivBtm - 0.5;
if (roadDivBtm < -20)
{
roadDivBtm = 100;
score++;
}

5.4 Score Board


glColor3f(0.000, 0.000, 0.000);
glBegin(GL_POLYGON);
glVertex2f(80, 97);
glVertex2f(100, 97);
glVertex2f(100, 98 - 8);
glVertex2f(80, 98 - 8);
glEnd();

5.4.1 Print Score


char buffer[50];
sprintf(buffer, "SCORE: %d", score);
glColor3f(0.000, 1.000, 0.000);
renderBitmapString(80.5, 95, (void *)font3, buffer);

5.4.2 Speed Print


char buffer1[50];
sprintf(buffer1, "SPEED:%dKm/h", FPS);

Dept Of CSE Page 21


Mini Project Report 2023-2024

glColor3f(0.000, 1.000, 0.000);


renderBitmapString(80.5, 95 - 2, (void *)font3, buffer1);
if (score % 50 == 0)
{
int last = score / 50;
if (last != level)
{
level = score / 50;
FPS = FPS + 2;
}
}
char level_buffer[50];
sprintf(level_buffer, "LEVEL: %d", level+1);
glColor3f(0.000, 1.000, 0.000);
renderBitmapString(80.5, 95 - 4, (void *)font3, level_buffer);

5.5 MAIN CAR


glColor3f(0.000, 0.000, 0.000);
glBegin(GL_POLYGON);
glVertex2f(lrIndex + 26 - 2, 5);
glVertex2f(lrIndex + 26 - 2, 7);
glVertex2f(lrIndex + 30 + 2, 7);
glVertex2f(lrIndex + 30 + 2, 5);
glEnd();
5.5.1 Back Tire
glColor3f(0.000, 0.000, 0.000);
glBegin(GL_POLYGON);
glVertex2f(lrIndex + 26 - 2, 1);
glVertex2f(lrIndex + 26 - 2, 3);
glVertex2f(lrIndex + 30 + 2, 3);
glVertex2f(lrIndex + 30 + 2, 1);
glEnd();
5.5.2 Car Body
glColor3f(0.678, 1.000, 0.184);

Dept Of CSE Page 22


Mini Project Report 2023-2024

glBegin(GL_POLYGON);
glVertex2f(lrIndex + 26, 1);
glVertex2f(lrIndex + 26, 8);
glColor3f(0.000, 0.545, 0.545);

glVertex2f(lrIndex + 28, 10);


glVertex2f(lrIndex + 30, 8);
glVertex2f(lrIndex + 30, 1);
glEnd();

glColor3f(1.000, 0.000, 0.000);


glBegin(GL_POLYGON);
glVertex2f(lrIndex1 + 26, car1 + 100);
glVertex2f(lrIndex1 + 26, car1 + 100 - 7);
glVertex2f(lrIndex1 + 28, car1 + 100 - 9);
glVertex2f(lrIndex1 + 30, car1 + 100 - 7);
glVertex2f(lrIndex1 + 30, car1 + 100);
glEnd();
car1--;
if (car1 < -100)
{
car1 = 0;
lrIndex1 = lrIndex;
}
//Kill check car1
if ((abs(lrIndex - lrIndex1) < 8) && (car1 + 100 < 10))
{
PlaySound(TEXT("MyAppSound"), NULL, SND_APPLICATION);
start = 0;
gv = 1;
}

);
glVertex2f(lrIndex2 + 26 - 2, car2 + 100);
glVertex2f(lrIndex2 + 26 - 2, car2 + 100 - 2);

Dept Of CSE Page 23


Mini Project Report 2023-2024

glVertex2f(lrIndex2 + 30 + 2, car2 + 100 - 2);

if (car2 < -100)


{
car2 = 0;
lrIndex2 = lrIndex;
}
//Kill check car2
if ((abs(lrIndex - lrIndex2) < 8) && (car2 + 100 < 10))
{
PlaySound(TEXT("MyAppSound"), NULL, SND_APPLICATION);
start = 0;
gv = 1;
}

5.6 Opposite car


glColor3f(0.000, 0.000, 0.000);
glBegin(GL_POLYGON);
glVertex2f(lrIndex3 + 26 - 2, car3 + 100 - 4);
glVertex2f(lrIndex3 + 26 - 2, car3 + 100 - 6);
glVertex2f(lrIndex3 + 30 + 2, car3 + 100 - 6);
glVertex2f(lrIndex3 + 30 + 2, car3 + 100 - 4);
glEnd();
glColor3f(0.000, 0.000, 0.000);
glBegin(GL_POLYGON);
glVertex2f(lrIndex3 + 26 - 2, car3 + 100);
glVertex2f(lrIndex3 + 26 - 2, car3 + 100 - 2);
glVertex2f(lrIndex3 + 30 + 2, car3 + 100 - 2);
glVertex2f(lrIndex3 + 30 + 2, car3 + 100);
glEnd();
glColor3f(1.000, 0.271, 0.000);
glBegin(GL_POLYGON);
glVertex2f(lrIndex3 + 26, car3 + 100);
glVertex2f(lrIndex3 + 26, car3 + 100 - 7);

Dept Of CSE Page 24


Mini Project Report 2023-2024

glVertex2f(lrIndex3 + 28, car3 + 100 - 9);


glVertex2f(lrIndex3 + 30, car3 + 100 - 7);
glVertex2f(lrIndex3 + 30, car3 + 100);
glEnd();
car3--;
if (car3 < -100)
{
car3 = 0;
lrIndex3 = lrIndex;
}
//Kill check car3
if ((abs(lrIndex - lrIndex3) < 8) && (car3 + 100 < 10))
{
PlaySound(TEXT("MyAppSound"), NULL, SND_APPLICATION);
start = 0;
gv = 1;
}
}

5.7 Road Design In Front Page


glColor3f(0, 0.3, 0.3);
glBegin(GL_TRIANGLES);
glVertex2f(32 - 2 + 21, 55);
glVertex2f(32 + 58, 50 - 50);
glVertex2f(32 - 22, 50 - 50);
glEnd();
//Road Middle
glColor3f(0.8, 0.8, 0);
glBegin(GL_TRIANGLES);
glVertex2f(32 - 2 + 21, 55);
glVertex2f(50 + 2, 50 - 50);
glVertex2f(50 - 2, 50 - 50);
glEnd();
//Road Sky

Dept Of CSE Page 25


Mini Project Report 2023-2024

glColor3f(0.000, 0.60, 1.000);


glBegin(GL_POLYGON);
glVertex2f(100, 100);
glColor3f(0.235, 0.702, 0.443);
glBegin(GL_TRIANGLES);
glVertex2f(87, 55 + 10);
glVertex2f(100, 55);
glVertex2f(60, 55);
glEnd();

5.8 Hill
glColor3f(0.000, 0.400, 0.000);
glBegin(GL_TRIANGLES);
glVertex2f(70, 70);
glVertex2f(90, 55);
glVertex2f(50, 55);
glEnd();

5.9 Tree on front page


tree(5, -15);
tree(0, 0);
tree(9, 5);
tree(80, 0);
tree(75, -15);
tree(72, 5);

5.10 Menu Place Holder


glColor3f(0.098, 0.098, 0.439);
glBegin(GL_POLYGON);
glVertex2f(32 - 4, 50 + 5 + 10);
glVertex2f(32 + 46, 50 + 5 + 10);
glVertex2f(32 + 46, 50 - 15 + 10);
glVertex2f(32 - 4, 50 - 15 + 10);
glEnd();

Dept Of CSE Page 26


Mini Project Report 2023-2024

glColor3f(00, 0, 0.000);
glBegin(GL_POLYGON);
glVertex2f(32 - 4, 50 + 5 + 10);
glVertex2f(32 + 46, 50 + 5 + 10);
glVertex2f(32 + 46, 50 + 4 + 10);
glVertex2f(32 - 4, 50 + 4 + 10);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(32 + 45, 50 + 5 + 10);
glVertex2f(32 + 46, 50 + 5 + 10);
glVertex2f(32 + 46, 50 - 15 + 10);
glVertex2f(32 + 45, 50 - 15 + 10);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(32 - 4, 50 - 14 + 10);
glVertex2f(32 + 46, 50 - 14 + 10);
glVertex2f(32 + 46, 50 - 15 + 10);
glVertex2f(32 - 4, 50 - 15 + 10);
glEnd();
glBegin(GL_POLYGON);
glVertex2f(32 - 4, 50 + 5 + 10);
glVertex2f(32 - 5, 50 + 5 + 10);
glVertex2f(32 - 5, 50 - 15 + 10);
glVertex2f(32 - 4, 50 - 15 + 10);
glEnd();
glColor3f(1.000, 1.000, 0.000);
renderBitmapString(30, 80, (void *)font1, "2D Car Racing Game ");
glColor3f(0.000, 1.000, 0.000);
renderBitmapString(30, 50 + 10, (void *)font2, "Press SPACE to Start");
renderBitmapString(30, 50 - 3 + 10, (void *)font2, "Press ESC to Exit");
glColor3f(1.000, 1.000, 1.000);
renderBitmapString(30, 50 - 6 + 10, (void *)font3, "Press UP to Increase Speed");
renderBitmapString(30, 50 - 8 + 10, (void *)font3, "Press DWON to Decrease Speed");
renderBitmapString(30, 50 - 10 + 10, (void *)font3, "Press RIGHT to Turn Right");

Dept Of CSE Page 27


Mini Project Report 2023-2024

renderBitmapString(30, 50 - 12 + 10, (void *)font3, "Press LEFT to Turn Left");


renderBitmapString(30 - 8, 50 - 43, (void *)font3, "152-15-6037");
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
if (start == 1)
{
glClearColor(0.000, 0.392, 0.000, 1);
startGame();
}
else
{
fristDesign();
}
glFlush();
glutSwapBuffers();
}
void spe_key(int key, int x, int y)
{
switch (key)
{
case GLUT_KEY_DOWN:
if (FPS > (50 + (level * 2)))
FPS = FPS - 2;
break;
case GLUT_KEY_UP:
FPS = FPS + 2;

}
}
void processKeys(unsigned char key, int x, int y)
{
switch (key)
{

Dept Of CSE Page 28


Mini Project Report 2023-2024

case ' ':


void timer(int)
{
glutPostRedisplay();
glutTimerFunc(1000 / FPS, timer, 0);
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutInitWindowSize(500, 650);
glutInitWindowPosition(200, 20);
glutCreateWindow("2D-Car-Game by MD SAQIB");
glutDisplayFunc(display);
glutSpecialFunc(spe_key);
glutKeyboardFunc(processKeys)
glOrtho(0, 100, 0, 100, -1, 1);
glClearColor(0.184, 0.310, 0.310, 1)
glutTimerFunc(1000, timer, 0);
glutMainLoop();

return 0;
}

Dept Of CSE Page 29


Mini Project Report 2023-2024

CHAPTER 6
TESTING

6.1 Testing
Testing is the process of executing a program to find the errors. A good test has the
high probability of finding a yet undiscovered error. A test is vital to the success of the
system. System test makes a logical assumption that if all parts of the system are correct,
then goal will be successfully achieved.
Input Expected Output Output Status
Car Model Mode This places the car Car is placed against
against a plain A plain background
background which is Which helps to view Success
helpful in viewing the the car model
car model
Car Driving Mode Car is placed on the Car is placed on the
road having road having Success
greenery on its sides greenery on its
sides
Fod Effect The entire display is The entire display is
covered with fog covered with fog Success

Wheel Effect The Effects on the The Effects on the


wheel are shown on Wheel are shown on Success
the Display of car
The display
model
Car Colors Various colors for the Various colors for
car can be chosen the car can be chosen Success

Day and Night Mode Entire display changes Entire display


accordingly changes Success
accordingly
Table 5.1: Testing

Dept Of CSE Page 30


Mini Project Report 2023-2024

6.1.1 Types of Testing


• Unit Testing

• Integration Testing

• System Testing

6.1.2 Unit Testing


Here we test the movement of each bird separately .Step by step testing is done to check
whether all the birds are placed at the correct positions, to check whether they are translated
properly and whether the target disappears or changes color when it is hit.

6.1.3 Integration Testing


All the patterns are called together and we add mouse functions and check whether it is
executing successfully, check whether the mouse input can be taken successfully are
displayed correctly.
Black box testing takes an external perspective of the test object to derive test
cases. These tests can be functional or non-functional, though usually functional. The test
designer selects valid and invalid inputs and determines the correct output. There is no
knowledge of the test object's internal structure.
This method of test design is applicable to all levels of software testing: unit,
integration, functional testing, system and acceptance. The higher the level, and hence the
bigger and more complex the box, the more one is forced to use black box testing to
simplify. While this method can uncover unimplemented parts of the specification, one
cannot be sure that all existent paths are tested. Bottom-Up Testing is an approach to
integration testing where the lowest level components are tested first, then used to facilitate
the testing of higher level components. The process is repeated until the component at the
top of the hierarchy is tested.
This project has been tested for its working and is found the requirements as mentioned.

The input device used is mouse which has been tested for correct operation.

Dept Of CSE Page 31


Mini Project Report 2023-2024

6.1.4 System Testing


The different components are integrated to make up the entire system. The testing process
is concerned with finding errors, which result from unanticipated interactions between the
different components. It is also concerned with validating that the system meets its
functional and non – functional requirements.
This testing procedure was carried out iteratively with addition of every new

component. The initial component was the creation of bird. This was system – tested with

the addition of translation of the bird. These two were retested with the case where the bird
hits the target and the target successfully disappears

Unit Testing

Integration
Testing
System
Testing

Dept Of CSE Page 32


Mini Project Report 2023-2024

CHAPTER 7
RESULTS

Figure 7.1 The Help Window.

The Help window displays the details about the usage of various keys and mouse
button in this project. It is immediately displayed when the program begins its execution.

Figure 7.2 Car in driving mode.

This is the display seen when driving mode is selected from the menu. All the effects
seen in car model mode can also be viewed in this mode by pressing appropriate keys and
options in menu.

Dept Of CSE Page 33


Mini Project Report 2023-2024

Figure 7.3 The display with menu.

This is the display obtained when the right mouse button is pressed and menus are
viewed. Here the car colors menu is chosen and a submenu called yellow is chosen. Hence
the car turned to yellow. Various options in the menu can be viewed in the above figure.

Figure 7.4 Car while Crashing

Dispaly while in the game the car is crashing with another car and the stops and
return to menu window.

Dept Of CSE Page 34


Mini Project Report 2023-2024

Conclusion
This game is an open world game that a player can enjoy without ever worrying
about game’s end. A player must complete the tasks in order to win the race. The Game
will consist of 2 scenes where every scene has its own environment.. The player will start
the game from starting point, and he will again come to that point at end. This Game is just
an initial version.

This game is a part of a bigger educational process is really in the core mind-set
that this project wants to promote. Games can do many things very well, but they certainly
cannot do everything at once .. Many new things learnt by implementing this I have went
through various events ,functions and keyboards in Unity .This project aimed as much at
using alternative and innovative methods to teach through coding digital games and
playing games as part of learning, as at developing the skills in extending academic goals
to understand, support and include the whole child: not only their academic subject skills
but also social, emotional and behavioural skills.

Dept Of CSE Page 35


Mini Project Report 2023-2024

References
• "Computer Networks: A Systems Approach" by Larry L. Peterson and Bruce S.
• "Traffic and Congestion Control in IP/TCP Networks" by Raghupathy Sivakumar,
• Prathima Agrawal, and Mohan Gurusamy
• Donald D Hearn, M Pauline Baker and WarrenCarithers: Computer Graphics with
OpenGL 4th
• Edition, Pearson, 2014
• S.Sridhar, Digital Image Processing, second edition, Oxford University press 2016.
• http://jerome.jouvie.free.fr/OpenGl/Lessons/Lesson3.php
• http://google.com
• http://opengl.org

Dept Of CSE Page 36

You might also like