Upload
sonu-pal
View
226
Download
0
Embed Size (px)
Citation preview
7/30/2019 Graphic Project
1/37
Project ReportIn the partial fulfillment of
Bachelor of Computer
Applications
On
The Game
Space jam
2011-2012
SUBMITTED TO:
SUBMITTED BY:
Mrs. APURVA SHARMA
RISHI SHARMA
7/30/2019 Graphic Project
2/37
18009000622
RAVINDER SINGH
18009000620
CERTIFICATE
This is to certify that the following students:
RISHI SHARMA RAVINDER SINGH
of B.C.A(III) have successfully completed their project work on
Space jam
in the partial fulfillment of requirement as prescribed by the PANJAB
UNIVERSITY, in the year 2011-2012.
Mrs. APURVA
SHARMA
7/30/2019 Graphic Project
3/37
PROJECT GUIDE
DECLARATION
We RISHI SHARMA & RAVINDER SINGH do hereby declare that this
project work, entitled SPACE JAM using graphics functions is a
record of project work carried by us under the supervision of Mrs.
Apurva Sharma in the partial fulfillment of the B.C.A program ofG.G.D.S.D COLLEGE, CHANDIGARH.
7/30/2019 Graphic Project
4/37
ACKNOWLEDGEMENT
When emotions are profound, words sometimes are not sufficient to
express our thanks and gratitude. With these few words we are trying to
express our gratitude to all those people who have helped and providedthe much needed enthusiasm and consistent encouragement. The
present shape of this study has come forth only after the contribution
from different spheres.
We sincerely express our deep gratitude to our project guide Mrs.
APURVA SHARMA for their valuable guidance, constructive
suggestions, constant encouragement and able supervision at each andevery step throughout this work.
7/30/2019 Graphic Project
5/37
We thank them whole-heartedly for their expert guidance,
encouragement, valuable suggestions and supervisions. Our sincere
thanks also go to our parents, friends and relatives for their ever
flowing love, care and timely guidance and encouragement.
PREFACE
We take pleasure and pride in presenting before you much worked out
project featuring the computers governing the latest running techniquein fields.
We submit our due thanks to Mr.VIRENDER SINGH (H.O.D), for
giving us the opportunity to emerge as a professional in the field of
COMPUTER. We extend our gratitude to Mrs. APURVA
SHARMA(lecturer) for supporting me in due course. The major part of
the appreciation goes to our respected LECTURER who has alwaysbeen imparting all the knowledge required.
We are thankful to our classmates who really assisted in conducting the
final points of this project.
7/30/2019 Graphic Project
6/37
With due pleasure, we submit our piece of labour in front of you. We
are sure it will be esteemed in a very deserving manner.
CONTENTS
1. INTRODUCTION TO PROJECT
2. WHAT IS COMPUTER GRAPHICS
3. FEASIBILITY STUDY
7/30/2019 Graphic Project
7/37
4. OBJECTIVE OF THE PROJECT
5. REQUIREMENTS OF THE PROJECT
6. C HEADER FILES USED
7. C FUNCTIONS
8. SCREENSHOTS OF THE PROJECT
9. REFERENCES
INTRODUCTION TO THE PROJECT
Our project is based on a game which is designed with some codes
using C-language. Programming is done to create a digital-based
visuals using COMPUTER GRAPHICS.
7/30/2019 Graphic Project
8/37
It is a simple game that shows a spaceship in space which shoots
digitally created enemy sapceships with digital BULLETS. It is
created using various techniques and functions supported in
graphics,such as- setcolor(),arc(),circle(),rectangle() etc.
To make it more interactive light effect and sound effects are also added
to the programming. For light effects setfillstyle(),floodfill() etc.
functions are used, and for audio sound() function is used.
The game can be played in a window sized screen which continuously
shows the playing screen. Several functions can be performed such asmoving the spaceship wherever on the screen as we move the MOUSE
POINTER .The bullets are fired wiht the use of left click.One bullet for
each click.
FEASIBILITY STUDY
7/30/2019 Graphic Project
9/37
The purpose of the Feasibility phase is to figure out
whether the proposed system development is giving long
term benefits more than the development cost or not. If the
idea of development is not feasibly possible then we have to
either change the idea or drop it.
1. Economic Feasibility:
The proposed project is having requirement of a computer system.
The client who is having the required equipment and facilities will
be able to run the S/W properly. So there is no additional cost for
implementing the project in the department under consideration.
Hence the project is economically feasible for the department.
2. Technical Feasibility:
Technical feasibility refers to the ability to develop the project
using technology in trade. The project under consideration is
technically possible using C programming language.
3. Operational Feasibility:
The potential candidates of the System under consideration are
the Faculty members & trainees. Though the games on this software
can be played by age 6+, all the candidates are well above thisrequirement. Both the trainees and Faculty in charge here are computer
literate so the project is operationally very much feasible.
7/30/2019 Graphic Project
10/37
WHAT IS COMPUTER GRAPHICS?
Computer graphics aregraphics created usingcomputers and, more
generally, the representation and manipulation ofimage data by a
computer with help from specialized software andhardware.
The development of computer graphics has made computers easier to
interact with, and better for understanding and interpreting many types
of data. Developments in computer graphics have had a profound
impact on many types of media and have revolutionizedanimation, movies and the video game industry.
http://en.wikipedia.org/wiki/Graphicshttp://en.wikipedia.org/wiki/Computerhttp://en.wikipedia.org/wiki/Imagehttp://en.wikipedia.org/wiki/Graphics_hardwarehttp://en.wikipedia.org/wiki/Movieshttp://en.wikipedia.org/wiki/Video_gamehttp://en.wikipedia.org/wiki/Graphicshttp://en.wikipedia.org/wiki/Computerhttp://en.wikipedia.org/wiki/Imagehttp://en.wikipedia.org/wiki/Graphics_hardwarehttp://en.wikipedia.org/wiki/Movieshttp://en.wikipedia.org/wiki/Video_game7/30/2019 Graphic Project
11/37
OBJECTIVE OF THE PROGRAM.
The objective of spce jam is to destroy the enemy spaceships who
wants to destroy the universe by obeying the rules given below:-
1. The game starts giving basics about the game such as ...the
world is coming to an end... ...the devil is going to destroy the
universe... .
2. We have unlimited bullets to fire, the aim is to destroy the devil
with bullets. .
3. After the warning game can be continued by pressing any key.
4. The functions in the game can be performed by pressing keys
such as 8 and 2 to move the gun vertically.
5. Bullets can be shot at the enemy by left clicking.
6. As the game starts we can see our spaceship at the lower bottom
of the screen and the enemy spaceships coming towards our
spaceships and firing bullets.
7. The main objective of the game is to take the target from the
point using the valid moves.
7/30/2019 Graphic Project
12/37
8. If you succeeded in shooting and destroying all of the enemy
spaceships,, a message will appear on screen saying
...YOU'VE...WON... .
9. If you failed to destroy all the enemy spaceships and also failed
to protect the spaceship from the enemy then game will be over
and the following message will appear DESTROYED GAME
OVER.
10.At the end an EXIT message will appear asking for your choice if
you want to exit the game or not. If you want to exit press Y if
you dont press N.
7/30/2019 Graphic Project
13/37
REQUIREMENTS OF THE PROJECT
HARDWARE REQUIREMENTS:
Processor 1.66MHz
RAM 24 MB
Monitor
Keyboard
Mouse
Hard Disk Drive At least 20MB and more
SOFTWARE REQUIREMENTS:
Operating System Window XP 2003
Turbo C++
7/30/2019 Graphic Project
14/37
C HEADER FILES USED:
: Most of the C file input/output functions are defined instdio.h.
: It contains functions for console input/output. Some
of the
most commonly used functions of conio.h are
clrscr(), getch() .
. : It contains functions for handling interrupts,producing
Sound , date and time functions etc.
: It is used to draw different shapes, display text in
different fonts, change colors.
: It is used to allocate memory on the local storage
space .
: This header defines several general purpose
functions,
7/30/2019 Graphic Project
15/37
including dynamic memory management, random
number
generation, communication with the environment,
integer
arithmetic, searching, sorting and converting.
C FUNCTIONS:
setcolor function in c :
Declaration :- void setcolor(int color);
In Turbo Graphics each color is assigned a number. Total 16 colors are
available. Strictly speaking number of available colors depends on
current graphics mode and driver.For Example :- BLACK is assigned 0,
RED is assigned 4 etc. setcolor function is used to change the currentdrawing color.e.g. setcolor(RED) or setcolor(4) changes the current
drawing color to RED. Remember that default drawing color is WHITE.
7/30/2019 Graphic Project
16/37
setfillstyle function in c :
setfillstyle function sets the current fill pattern and fill color.
Declaration :- void setfillstyle( int pattern, int color);
setfillstyle(SOLID_FILL,RED);
Pattern tells that which type of pattern has to be filled and color
specifies the color with which the pattern must be filled.
circle function in c :
Declaration :- void circle(int x, int y, int radius);
e.g. circle(50,50,15);
circle function is used to draw a circle with center (x,y) and third
parameter specifies the radius of the circle. The code given below
draws a circle.
floodfill function :
Declaration :- void floodfill(int x, int y, int border);
7/30/2019 Graphic Project
17/37
e.g. floodfill(50,50,WHITE);
floodfill function is used to fill an enclosed area. Current fill pattern
and fill color is used to fill the area.(x, y) is any point on the screen if
(x,y) lies inside the area then inside will be filled otherwise outside will
be filled,border specifies the color of boundary of area. To change fill
pattern and fill color use setfillstyle. Code given below draws a circle
and then fills it.
rectangle function in c :
Declaration :- void rectangle(int left, int top, int right, int bottom);
e.g. rectangle(0,0,maxx,maxy);
rectangle function is used to draw a rectangle. Coordinates of left top
and right bottom corner are required to draw the rectangle. Left
specifies the X-coordinate of top left corner, top specifies the Y-
coordinate of top left corner, right specifies the X-coordinate of right
bottom corner, bottom specifies the Y-coordinate of right bottom
corner. The code given below draws a rectangle.
arc function in c :
Declaration :- void arc(int x, int y, int stangle, int endangle, int radius);
e.g. arc(25,25,335,360,40);
arc function is used to draw an arc with center (x,y) and stangle
specifies starting angle, endangle specifies the end angle and last
7/30/2019 Graphic Project
18/37
parameter specifies the radius of the arc. arc function can also be used
to draw a circle but for that starting angle and end angle should be 0
and 360 respectively.
setviewport function in c :
setviewport function sets the current viewport for graphics output.
e.g. setviewport(1,1,maxx-1,maxy-1,1);
Declaration :- void setviewport(int left, int top, int right, int bottom, int
clip);
setviewport function is used to restrict drawing to a particular portion
on the screen. For example setviewport(100 , 100, 200, 200, 1);
will restrict our drawing activity inside the rectangle(100,100, 200,
200).
left, top, right, bottom are the coordinates of main diagonal of rectangle
in which we wish to restrict our drawing. Also note that the point (left,
top) becomes the new origin.
settextstyle function in c :
Settextstyle function is used to change the way in which text appears,
using it we can modify the size of text, change direction of text and
change the font of text.
7/30/2019 Graphic Project
19/37
e.g. settextstyle(1,0,3);
Declaration :- void settextstyle( int font, int direction, int charsize);
font argument specifies the font of text, Direction can be HORIZ_DIR
(Left to right) or VERT_DIR (Bottom to top).
outtextxy function in c :
outtextxy function display text or string at a specified point(x,y) on the
screen.
Declaration :- void outtextxy(int x, int y, char *string);
e.g. outtextxy(maxx/2,30,"...the world is coming to an end...");
x, y are coordinates of the point and third argument contains the
address of string to be displayed.
fillellipse function in c :
fillellipse is used to fill the ellipse drawn on the screen.
Declaration of fillellipse function :-
void fillellipse(int x, int y, int xradius, int yradius);x and y are coordinates of center of the ellipse, xradius and yradius are
x and y radius of ellipse respectively.
7/30/2019 Graphic Project
20/37
getimage function in c :
getimage function saves a bit image of specified region into memory,
region can be any rectangle.
Declaration:- void getimage(int left, int top, int right, int bottom, void
*bitmap);
e.g. getimage(25,25,75,75,buff);
getimage copies an image from screen to memory. Left, top, right, and
bottom define the area of the screen from which the rectangle is to be
copied, bitmap points to the area in memory where the bit image is
stored.
putimage function in c :
putimage function outputs a bit image onto the screen.
Declaration:- void putimage(int left, int top, void *ptr, int op);
e.g. putimage(25,25,buff,XOR_PUT);
putimage puts the bit image previously saved with getimage back onto
the screen, with the upper left corner of the image placed at (left, top).
ptr points to the area in memory where the source image is stored. The
op argument specifies a operator that controls how the color for each
destination pixel on screen is computed, based on pixel already on
screen and the corresponding source pixel in memory.
7/30/2019 Graphic Project
21/37
putpixel function in c :
putpixel function plots a pixel at location (x, y) of specified color.
Declaration :- void putpixel(int x, int y, int color);
e.g. putpixel(random(maxx),random(maxy),random(16));
For example if we want to draw a GREEN color pixel at (35, 45) then
we will write putpixel(35, 35, GREEN); in our c program, putpixel
function can be used to draw circles, lines and ellipses using various
algorithms.
setfillstyle function in c :
setfillstyle function sets the current fill pattern and fill color.
Declaration :- void setfillstyle( int pattern, int color);
e.g setfillstyle(SOLID_FILL,15);
closegraph function in c:
closegraph function closes the graphics mode, deallocates all memory
allocated by graphics system and restores the screen to the mode it was
in before you called initgraph.
7/30/2019 Graphic Project
22/37
Declaration :- void closegraph();
getmaxx function in c:
getmaxx function returns the maximum X coordinate for current
graphics mode and driver.
Declaration :- int getmaxx();
getmaxy function in c:
getmaxy function returns the maximum Y coordinate for current
graphics mode and driver.
Declaration :- int getmaxy();
delay function in c :
7/30/2019 Graphic Project
23/37
Delay in c: delay function is used to suspend execution of a program for
a particular time.
Declaration :- void delay(unsigned int);
e.g. delay(4000);
Here unsigned int is the number of milliseconds ( remember 1 second =
1000 milliseconds ). To use delay function in your program you should
include the dos.h header file.
sound function in c:
Declaration :
Void sound(int value);
e.g. sound(500);
Sound function is used to produce the audio effects with a parameter
int value.
SCREENSHOTS OF THE PROECT
7/30/2019 Graphic Project
24/37
There are some screenshots of the project, showing the outline of the
project
and the various actions which we can apply on it.
SCREENSHOT 1:
This shows the introductory face of the game which tells about the
worlds coming to an end and informing you to destroy the devil before
it destroys you.
7/30/2019 Graphic Project
25/37
SCREENSHOT 2:
The main front view of the project showing the objective and actions
that can be performed by the user in the game to SHOOT THE
DEVIL.
7/30/2019 Graphic Project
26/37
SCREENSHOT 3:
This is the actual starting face of the game, the white bold dot at the
extreme left is the GUN that shoots the bullets at the DEVIL
shown in red on the screen. At the top we can see the number of bullets
were left with which are at its initial in this shot i.e. 10.
7/30/2019 Graphic Project
27/37
SCREENSHOT 4:
This is the snapshot when there are still 8 bullets left with the players
and it shoots the devil. As soon as the bullet hits the devil, the
screenshot 4 appears to the player.
7/30/2019 Graphic Project
28/37
SCREENSHOT 5:
This shot appears when the devil is destroyed and the world is saved. It
displays the message YOUVE WON.
7/30/2019 Graphic Project
29/37
SCREENSHOT 6:
These are some other screenshots from the game where devil is moving
within the screen. Number of bullets left are 7. with each passing shot
the number of shots displayed on the screen will be reduced , updating
you about the number of shots left .
7/30/2019 Graphic Project
30/37
SCREENSHOT 7:
Now the devil has moved to upper part of the screen and number ofshots left with the player has reduced to 6.
7/30/2019 Graphic Project
31/37
SCREENSHOT 8:
The player has lost one more shot without hitting the target and now the
number of shots left is 4.
7/30/2019 Graphic Project
32/37
SCREENSHOT 9:
7/30/2019 Graphic Project
33/37
Now the player is left with just 2 last shots with which he has to shoot
the target else hell lost the game.
SCREENSHOT 10:
7/30/2019 Graphic Project
34/37
This is the last shot left with the player to destroy the devil , if the player
failed to hit it this time too, hell lose the game and the game will be
over.
SCREENSHOT 11:
7/30/2019 Graphic Project
35/37
This shot shows that the bullets are over with the player and that he
failed to shoot the target. The message Your bullets are over
The devil destroys the world will be displayed on the screen. And that
marks the end of the game.
7/30/2019 Graphic Project
36/37
CONCLUSION
The project report entitled "SPACE JAM" has come to its final
stage. The system has been developed with much care that it is free of
errors and at the same time it is efficient and less time consuming. The
important thing is that the system is robust. We have tried our level best
to make the game as dynamic as possible. Also provision is provided for
future developments in the system. The entire system is secured.
7/30/2019 Graphic Project
37/37
BIBLIOGRAPHY and REFERENCES
http://www.123eng.com/sourcecode/c/games&graphics/shoot
_the_devil.html
WWW.CPROGRAMMINGREFERENCE.COM
http://books.google.co.in/bkshp?hl=en&tab=wp
Computer Graphics D.T Mukherjee and Debasish
C++ - Anshuman Sharma
http://www.123eng.com/sourcecode/c/games&graphics/shoot_the_devil.htmlhttp://www.123eng.com/sourcecode/c/games&graphics/shoot_the_devil.htmlhttp://www.cprogrammingreference.com/http://books.google.co.in/bkshp?hl=en&tab=wphttp://www.123eng.com/sourcecode/c/games&graphics/shoot_the_devil.htmlhttp://www.123eng.com/sourcecode/c/games&graphics/shoot_the_devil.htmlhttp://www.cprogrammingreference.com/http://books.google.co.in/bkshp?hl=en&tab=wp