0% found this document useful (0 votes)
16 views19 pages

CG Mini Project Format

Cg mini project

Uploaded by

sayleebandal312
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views19 pages

CG Mini Project Format

Cg mini project

Uploaded by

sayleebandal312
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

lOMoARcPSD|39464413

CG MINI Project Format

Computer Engineering (Savitribai Phule Pune University)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

A
Mini Project
Report on

“Title of Mini Project”

SUBMITTED TO THE SAVITRIBAI PHULE PUNE UNIVERSITY, PUNE IN


PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE AWARD OF

SECOND YEAR COMPUTER ENGINEERING

SUBMITTED BY
SARVESH SHAHANE ROLL NO -49
ADITYA MODAK ROLL NO –
33 PRANAV NIMJE ROLL NO -
35

UNDER THE GUIDANCE OF


Prof.S.P.BAMANE

DEPARTMENT OF COMPUTER ENGINEERING


TSSM’s
PADMABHOOSHAN VASANTDADA PATIL INSTITUTE OF
TECHNOLOGY,BAVADHAN, PUNE-21.
2022-23

AFFILIATED TO

pg. 1
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

CERTIFICATE
This is to certify that the seminar report entities

“ 2D GAMING ”
Submitted by
SARVESH SHAHANE ROLL NO – 49
ADITYA MODAK ROLL NO – 33
PRANAV NIMJE ROLL NO – 35

is a bonafide work carried out by above students under the guidance of


Prof.Shobha Bamane and it is approved for the Computer Graphics Laboratory
– Mini Project fulfilment of the requirement of Savitribai Phule PuneUniversity.

Prof. S.P.BAMANE Prof. G.S.WAYAL


Subject Teacher HOD, Computer Engineering

Dr.R S.Pawar
Principal
PADMABHOOSHAN VASANTDADA PATIL INSTITUTE OF
TECHNOLOGY,BAVADHAN, PUNE-21.

Place: PVPIT Bavdhan ( PUNE )


Date: 26 / 12 /2022

pg. 2
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

ACKNOWLEDGEMENT

With due respect and gratitude Itake the opportunity to thank those who have Helped
medirectly and indirectly. I convey my sincere thanks to Prof.G.S.Wayal HoD of computer
Department. and Prof. Shobha Bamane their help in selecting The mini project topic and
support. I thank to my seminar guide Prof. Prof.Shobha Bamane for her guidance, timely
Help and valuable suggestions without which this seminar would not have been. Possible.
Her direction has always been encouraging as well as inspiring for me. Attempts have been
made to minimize the errors in the report. I would also like to express my appreciation and
thanks to all my friends who Knowingly have assisted and encourage me throughout my hard
Work.

pg. 3
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

ABSTRACT

The broad objective of this study is an attack, threat and vulnerabilities of cyber
infrastructure, which include hardware and software systems, networks, enterprise networks,
intranets, and its use of the cyber intrusions. To achieve this objective, the paper attempts to
explain the importance g in network intrusions and cyber-theft. It also discusses in vivid
detail, the reasons for the quickdilation of cybercrime. The paper also includes a complete
description and definition of cyber security, the role it plays in network intrusion and cyber
recognize theft, a discussion of the reasons for the rise in cybercrime and their impact. In
closing the authors recommend some preventive measures and possible solutions to the
attack, threats and vulnerabilities of cyber security. The paper concludes that while
technology has a role to play in reducing the impact of cyber attacks, the vulnerability resides
with human behaviour and psychological predispositions. While literature supports the
dangers of psychological susceptibilities in cyber attacks investment in organizational
education campaigns offer optimism that cyber attacks can be reduced

pg. 4
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

INTRODUCTION

In the project “ 2D GAME”, the project is programmed using c/c++ .


Oops concepts are explored and the project involves the Bat and Ball
on which basis game is built.In this game there will be two players .
PC will be the First player and USER will be the second player. This
program contains Functions to drag the ball, draw the bat etc.
This project includes the multiple windows, menus and submenus
using which color of the bat & ball, screen color, ball size will be
changed. These all actions are assigned to keyboard and mouse.
User-interface is provided by means of both Keyboard and
Mouse. By using arrow keys bat can be moved. Mouse interaction is
achieved by means of a menu which is operational only with the “right
mouse button” through which bat,ball,screen color changing,speed
settings are enabled.

pg. 5
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

1.1 Computer Graphics:

Graphics provides one of the most natural means of communicating within a computer,
since our highly developed 2D and 3D pattern-recognition abilities allow us to perceive
and process pictorial data rapidly and effectively. Interactive computer graphics is the
most important means of producing pictures since the invention of photography and
television. It has the added advantage that, with the computer, we can make pictures
not only of concrete real world objects but also of abstract, synthetic objects, such as
mathematical surfaces and of data that have no inherent geometry, such as survey
results.
Computer graphics started with the display of data on hardcopy plotters and cathode
ray tube screens soon after the introduction of computers themselves. It has grown to
include the creation, storage, and manipulation of models and images of objects. These
models come from a diverse and expanding set of fields, and include physical,
mathematical, engineering, architectural, and even conceptual structures, natural
phenomena, and so on. Computer graphics today is largely interactive. The user
controls the contents, structure, and appearance of the objects and of their displayed
images by using input devices, such as keyboard, mouse, or touch-screen.
Due to close relationships between the input devices and the display, the handling of
such devices is included in the study of computer graphics. The advantages of the
interactive graphics are many in number. Graphics provides one of the most natural
means of communicating with a computer, since our highly developed 2D and 3D
patter-recognition abilities allow us to perceive and process data rapidly and
efficiently.
In many design, implementation, and construction processes today, the information
pictures can give is virtually indispensable. Scientific visualization became an important
field in the 1980s when the scientists and engineers realized that they could not interpret
the prodigious quantities of data produced in supercomputer runs without summarizing
the data and highlighting trends and phenomena in various kinds of graphical
representations.

1.2 OpenGL Interface:


OpenGL is an application program interface (API) offering various functions to
implement primitives, models and images. This offers functions to create and
manipulate render lighting, coloring, viewing the models. OpenGL offers different
coordinate system and frames. OpenGL offers translation, rotation and scaling of
objects.
Most of our applications will be designed to access OpenGL directly through functions
in three libraries. They are:
Main GL: Library has names that begin with the letter gl and are stored in a library
usually referred to as GL.
OpenGL Utility Library (GLU): This library uses only GL functions but contains code
for creating common objects and simplifying viewing.
OpenGL Utility Toolkit (GLUT): This provides the minimum functionality that should
be accepted in any modern windowing system.

1.3 OpenGL Overview:


OpenGL(Open Graphics Library) is the interface between a graphic program and
graphics hardware. It is streamlined. In other words, it provides low-level functionality.

pg. 6
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

For example, all objects are built from points, lines and convex polygons. Higher level
objects like cubes are implemented as six four-sided polygons.
OpenGL supports features like 3-dimensions, lighting, anti-aliasing, shadows, textures,
depth effects, etc.
It is system-independent. It does not assume anything about hardware or operating
system and is only concerned with efficiently rendering mathematically described
scenes. As a result, it does not provide any windowing capabilities.
It is a state machine. At any moment during the execution of a program there is a
current model transformation
It is a rendering pipeline. The rendering pipeline consists of the following steps:
Defines objects mathematically.
Arranges objects in space relative to a viewpoint.
Calculates the color of the objects.
Rasterizes the objects.

pg. 7
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

Future prospects:

Further this project can be enhanced by adding few more options i,e menus in game.
Using this we can design a 3D game which contains cube instead of single window and
multiple number of balls which are randomly moving and all faces of cube is considered
as wall.

pg. 8
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

pg. 9
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

pg. 10
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

pg. 11
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

pg. 12
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

CODE -

#include <GL/glut.h>
#include <stdio.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include<string.h>
#define bool int
#define true 1
#define false 0
#define FROM_RIGHT 1
#define FROM_LEFT 2
#define FROM_TOP 3 #define FROM_BOTTOM 4
int game=0; int p=0; int a,b,c,d; static mouse_x=0; static int value = 0; static int submenu_id; static
int bmenu_id; static int menu_id; static int nu_id; static int id; static int window;
double r1=1,g1=1,b1=1,r2=1,g2=1,b2=1.0; static int z=0;
static int WINDOW_WIDTH ,WINDOW_HEIGHT; int playerResult=0; int pcResult =0;
static float Xspeed=1,Yspeed=1; //for moving ball static float delta=1; //ball movements in
steps char string [100]; static int sizeb=0;

//structure for drawing ball and bat typedef struct RECTA


{
float left,top,right,bottom;
}RECTA;

RECTA ball={10,10,20,20};
RECTA wall ;
RECTA player_1 ={100,490,40,500};

//increase ball size void incsize(RECTA rect)


{
ball.right+=10; ball.bottom+=10;
}

//decrease ball size void decsize(RECTA rect) {


if(ball.left<ball.right)
{
ball.left+=10; ball.top+=10;
}
}

//drawing ball
void DrawBall(RECTA rect,double r,double g,double b)
{
glColor3f(r,g,b); glBegin(GL_QUADS);
glVertex2f(rect.left,rect.bottom); glVertex2f(rect.right,rect.bottom);
glVertex2f(rect.right,rect.top); glVertex2f(rect.left,rect.top); glEnd();
}

//drawing bat

pg. 13
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

void DrawBat(RECTA rect,double r,double g,double b)


{
glColor3f(r,g,b); glBegin(GL_QUADS);
glVertex2f(rect.left,rect.bottom); glVertex2f(rect.right,rect.bottom);
glVertex2f(rect.right,rect.top); glVertex2f(rect.left,rect.top); glEnd();
}

//timer funtion for moving ball void Timer(int v)


{
ball.left+=Xspeed; ball.right+=Xspeed; ball.top+=Yspeed; ball.bottom+=Yspeed;
glutTimerFunc(1,Timer,1);
}

//drawing text
void drawText(char* string,int x, int y)
{ int len, i; glRasterPos2f(x,y); len=(int) strlen(string); for(i = 0; i < len; i++)
{
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,string[i]); }
}

//test collision between ball and wall int Test_Ball_Wall(RECTA ball , RECTA wall)
{
if(ball.right >=wall.right) return FROM_RIGHT; if(ball.left <=wall.left) return
FROM_LEFT; if(ball.top <=wall.top) return FROM_TOP; if(ball.bottom >=wall.bottom)
return FROM_BOTTOM; else return 0 ;
}

//calculating score
bool Test_Ball_Player(RECTA ball,RECTA player)
{
if(ball.bottom >= player.top && ball.left>= player.left && ball.right <=player.right )
{
playerResult++; return true;
}
return false;
}

//repositioning ball void rend(RECTA rect)


{ ball.left=10; ball.top=10; ball.right=20; ball.bottom=20;
}
void rendp(RECTA rect)
{ a=ball.left; b=ball.top; c=ball.right; d=ball.bottom;
} void rendr(RECTA rect)
{ ball.left=a; ball.top=b; ball.right=c; ball.bottom=d;
}

//key Board Messages


void keyboard(unsigned char key, int x, int y)
{
switch (key)
{
case 'e':exit(0);break; case 'n'|'N':startscreenn();break; case '1':choice1();break;
case '2':renderr2();break; case '3':exit(0);break; case '4':winscreenn();break; case
'p':rendp(ball);pause11();break; case 'r':rendr(ball);renderr1();break; case
'c':rend(ball);delta=1;pcResult=0;playerResult=0;game=0;renderr1();bre ak; case
'a':rend(ball);delta=1;pcResult=0;playerResult=0;game=1;renderr1();bre ak; }
}

pg. 14
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

//key Board Message


void inputKey(int key, int x, int y)
{
switch (key)
{
case GLUT_KEY_LEFT :decsize(ball);break; case GLUT_KEY_R…

pg. 15
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

Conclusion:

The project was started with modest aim with no prior experience in any
programming projects as this, but ended up in learning many things, fine tuning
the programming skills and getting into the real world of software development
with an exposure to corporate environment. During the development of any
software of significant utility, we are forced with the tradeoff between speed of
execution and amount of memory consumed. This is simple interactive
application. It is extremely user friendly and has the features, which makes
simple graphics project. It has an open source and no security features has been
included. The user is free to alter the code for feature enhancement. Checking and
verification of all possible types of the functions are taken care. Care was taken to
avoid bugs. Bugs may be reported to creator as the need.

pg. 16
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

References :

1) GOOGLE
2) GEEKS FOR GEEKS FOR CONCEPT

2.1 HARDWARE REQUIREMENTS:


Dual Core Processor
2GB RAM
40GB Hard disk
DVD drive
Mouse and other pointing devices
Keyboard

2.2 SOFTWARE REQUIREMENTS:


Programming language – C/C++ using OpenGL
Operating system – Linux operating system
Compiler – C Compiler
Graphics library – GL/glut.h OpenGL 2.0

2.3 FUNCTIONAL REQUIREMENTS:


OpenGL APIs:
If we want to have a control on the flow of program and if we want to interact with the
window system then we use OpenGL API’S. Vertices are represented in the same
manner internally, whether they are specified as two-dimensional or
threedimensional entities, everything that we do are here will be equally valid in three
dimensions.
Although OpenGL is easy to learn, compared with other APIs, it is nevertheless
powerful. It supports the simple three dimensional programs and also supports the
advanced rendering techniques.

pg. 17
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])
lOMoARcPSD|39464413

2D GAMING

pg. 18
DEPARTMENT OF COMPUTER ENGINEERING
Downloaded by Saylee Bandal ([email protected])

You might also like