Balloon Shooting Game Using C Graphics: Integrated Project Report

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 39

INTEGRATED PROJECT REPORT

On
BALLOON SHOOTING GAME USING C
GRAPHICS
Submitted in partial fulfilment of the requirement for the
Course Integrated Project-II (CSP2204) of

COMPUTER SCIENCE AND ENGINEERING


Batch-2013

in

May-2015

Under the Guidance of: Submitted By:


Ms Palak Makhija
Mittul Saini
Id. No. B130010075
Pariyeksh Chauhan
Id. No. B130010076
Jatin Rana
Id. No.B130010416
Komal Guleria
Id. No. __________

DEPARTMENT OF COMPUTER SCIENCE & NGINEERING


CHITKARA UNIVERSITYHIMACHAL PRADESH
INTEGRATED PROJECT REPORT
On
BALLOON SHOOTING GAME USING C
GRAPHICS
Submitted in partial fulfilment of the requirement for the
Course Integrated Project-II (CSP2204) of

COMPUTER SCIENCE AND ENGINEERING


Batch-2013

in

May-2015

Under the Guidance of: Submitted By:


Ms Palak Makhija
Mittul Saini
Id. No. B130010075
Pariyeksh Chauhan
Id. No. B130010076
Jatin Rana
Id. No.B130010416
Komal Guleria
Id. No. __________

DEPARTMENT OF COMPUTER SCIENCE & NGINEERING


CHITKARA UNIVERSITYHIMACHAL PRADESH
CERTIFICATE

This is to be certified that the project entitled “Balloon Shooting game using C-graphics” has been submitted
for the Bachelor of Computer Science Engineering at Chitkara University, Himachal Pradesh during the
academic semester January 2015- May-2015 is a bonafide piece of project work carried out by “Mittul Saini-
B130010075,Pariyeksh Chauhan-B130010076,Jatin Rana-B130010416” towards the partial fulfilment for the
award of the course Integrated Project (CSP-2204) under the guidance of “Ms Palak Makhija” and supervision.

Signature of Project Guide


:

Ms Palak Makhija

(Ass. Professor, CSE)


CANDIDATE’S DECLARATION

We, Mittul Saini-B130010075,Pariyeksh Chauhan-B130010076,Jatin Rana-B130010416, B.E.-2013 of the


Chitkara University, Himachal Pradesh hereby declare that the Integrated Project Report entitled “Balloon
Shooting Game using C-graphics” is an original work and data provided in the study is authentic to the best
of our knowledge. This report has not been submitted to any other Institute for the award of any other course.

Sign. of Student 1 Sign. of Student 2 Sign. of Student 3


Mittul Saini Pariyeksh Chauhan Jatin Rana
B130010075 B130010076 B130010416

Place: Chitkara University


Date: May-26-2015
ACKNOWLEDGEMENT

It is our pleasure to be indebted to various people, who directly or indirectly contributed in the development of
this work and who influenced our thinking, behaviour and acts during the course of study.

We express our sincere gratitude to all for providing an opportunity to undergo Integrated Project-II as the
part of the curriculum.

We are thankful to “Ms Palak Makhija” for his/her support, cooperation, and motivation provided to us
during the training for constant inspiration, presence and blessings.

Lastly, we would like to thank the almighty and our parents for their moral support and friends with whom we
shared our day-to day experience and received lots of suggestions that improve our quality of work.

Mittul Saini Pariyeksh Chauhan Jatin Rana


B130010075 B130010076 B130010416
ABSTRACT

The aim of this report was to investigate c graphics and understanding various functions. For the
purposes of this report we have designed a balloon shooting game in c graphics , compiled on
turbo c. It has been seen that in todays modern worl, game has become like an important aspect
in our day to day life for relaxing purpose. The gamming world has flourished a lot since its
beginning . In our project while making of this we went through many different functions like :
Initgraph, Graphdriver , Graphmode , Path driver , Line function , Setcolor, Malloc , Getimage ,
Putimage , Delay.

1.0 INTRODUCTION TO THE PROJECT


The Balloon Shooting game is simple game using c and c++ features. The main features
included are Graphics and DOS command.

To run this program, you need graphics.h header file, graphics.lib library file and Graphics
driver (BGI file) in the program folder. These files are part of Turbo C package. In all our
programs we used 640x480 VGA monitor. So all the programs are according to that
specification. You need to make necessary changes to your programs according to your
screen resolution. For VGA monitor, graphics driver used is EGAVGA.BGI.
    Here, initgraph() function initializes the graphics mode and clears the screen. We will
study the difference between text mode and graphics mode in detail latter.

Declaration:

void far initgraph(int far *graphdriver, int far *graphmode, char far *pathtodriver);

Remarks: To start the graphics system, you must first call initgraph.

initgraph initializes the graphics system by loading a graphics driver from disk (or validating a
registered driver) then putting the system into graphics mode.

initgraph also resets all graphics settings (color, palette, current position, viewport, etc.) to their
defaults, then resets graphresult to 0.

pathtodriver : Specifies the directory path where initgraph looks for graphics drivers (*.BGI)
first. If they're not there, initgraph looks in the current directory. If pathtodriver is null, the
driver files must be in the current directory. This is also the path settextstyle searches for the
stroked character font files (*.CHR).
1.1 BACKGROUND

Turbo C++ was a C++ compiler and integrated development environment and computer
language originally from Borland. Most recently it was distributed by Embarcadero
Technologies, which acquired all of Borland's compiler tools with the purchase of its Code Gear
division in 2008. The original Turbo C++ product line was put on hold after 1994 and was
revived in 2006 as an introductory-level IDE, essentially a stripped-down version of their
flagship C++Builder. Turbo C++ 2006 was released on September 5, 2006 and was available in
'Explorer' and 'Professional' editions. The Explorer edition was free to download and distribute
while the Professional edition was a commercial product. In October 2009 Embarcadero
Technologies discontinued support of its 2006 C++ editions. As such, the Explorer edition is no
longer available for download and the Professional edition is no longer available for purchase
from Embarcadero Technologies. Turbo C++ is succeeded by C++Build.

HISTORY :

The first release of Turbo C++ was made available during the MS-DOS era on personal
computers. Version 1.0, running on MS-DOS, was released in May 1990. An OS/2 version was
produced as well. Version 1.01 was released on February 28, 1991,[1] running on MS-DOS. The
latter was able to generate both COM and EXE programs and was shipped with Borland's Turbo
Assembler compiler for Intel x86 processors. The initial version of the Turbo C++ compiler was
based on a front end developed by TauMetric (TauMetric was later acquired by Sun
Microsystems and their front end was incorporated in Sun C++ 4.0, which shipped in 1994).This
compiler supported the AT&T 2.0 release of C++.
Turbo C++ 3.0 was released in 1991 (shipping on November 20), and came in amidst
expectations of the coming release of Turbo C++ for Microsoft Windows. Initially released as an
MS-DOS compiler, 3.0 supported C++ templates, Borland's inline assembler, and generation of
MS-DOS mode executables for both 8086 real mode and 286 protected mode(as well as the
Intel 80186.) 3.0 implemented AT&T C++ 2.1, the most recent at the time. The separate Turbo
Assembler product was no longer included, but the inline-assembler could stand in as a reduced
functionality version.
Soon after the release of Windows 3.0, Borland updated Turbo C++ to support Windows
application development. The Turbo C++ 3.0 for Windows product was quickly followed
byTurbo C++ 3.1 (and then Turbo C++ 4.5). It's possible that the jump from version 1.x to
version 3.x was in part an attempt to link Turbo C++ release numbers with Microsoft Windows
versions; however, it seems more likely that this jump was simply to synchronize Turbo C and
Turbo C++, since Turbo C 2.0 (1989) and Turbo C++ 1.0 (1990) had come out roughly at the
same time, and the next generation 3.0 was a merger of both the C and C++ compiler.
Starting with version 3.0, Borland segmented their C++ compiler into two distinct product-lines:
"Turbo C++" and "Borland C++". Turbo C++ was marketed toward the hobbyist and entry-level
compiler market, while Borland C++ targeted the professional application development market.
Borland C++ included additional tools, compiler code-optimization, and documentation to
address the needs of commercial developers. Turbo C++ 3.0 could be upgraded with separate
add-ons, such as Turbo Assembler and Turbo Vision 1.0.
Version 4.0 was released in November 1993 and was notable (among other things) for its robust
support of templates. In particular, Borland C++ 4 was instrumental in the development of
the Standard Template Library, expression templates, and the first advanced applications
of template metaprogramming. With the success of the Pascal-evolved product Delphi, Borland
ceased work on their Borland C++ suite and concentrated on C++Builder for Windows. C+
+Builder shared Delphi's front-end application framework, but retained the Borland C++ back-
end compiler.

Earlier graphic game :


Pong is released. In 1966, Ralph Baer designed a ping-pong game for his Odyssey gaming
console. Nolan Bushnell played this game at a Magnavox product show in Burlingame,
California. Bushnell hired young engineer Al Alcorn to design a car driving game, but when it
became apparent that this was too ambitious for the time, he had Alcorn to design a version of
ping-pong instead. The game was tested in bars in Grass Valley and Sunnyvale, California where
it proved very popular. Pong would revolutionize the arcade industry and launch the modern
video game era.

“Doom” is released. id Software released Doom in late 1993. An immersive first-person shooter-
style game, Doom became popular on many different platforms before losing popularity to
games like Halo and Counter-Strike. Doom players were also among the first to customize the
game’s levels and appearance. Doom would spawn several sequels and a 2005 film.

SuperPaint is completed. SuperPaint was the first digital computer drawing system to use a
frame buffer—a special high-speed memory—and the ancestor of all modern paint programs. It
could create sophisticated animations, in up to 16.7 million colors, had adjustable paintbrushes,
video magnification, and used a graphics tablet for drawing. It was designed by Richard Shoup
and others at the Xerox Palo Alto Research Center (PARC). Its designers won a technical
Academy Award in 1998 for their invention.
1.2 PROBLEM STATEMENT
The problem statement is one of the most critical aspects of PBL, and one of the areas where
the experience of the supervisor can be vital for the success of a project. The major
problem statement was to implement the code, as it was hard to compile and run
successfully. Working on function like drawing, bursting were quite difficut to frame in a
working manner.
2.0 Software and Hardware Requirement Specification
To start with graphics programming, Turbo C is a good choice. Even though DOS has its own
limitations, it is having a large number of useful functions and is easy to program. To implement
graphics algorithms, To give graphical display of statistics, To view signals from any source, we
can use C graphics. Here is a article to start programming with Turbo C. 'Run and Learn' is our
method. We have used source codes throughout the explanations. Just execute them to
understand what is happening.

2.1 Methods
We decide that we will design our game using c graphics in which we will make balloons and
will move them using for loop and kbhit function and will draw a bow and arrow using functions
like draw arrow ,draw bow.

When the arrow will hit the balloon the burst function will be used and will increase the score of
the player by one .

The aim of the game is to shoot the balloons and score as much points as you can . Platform used
is Turbo C++ IDE . Standard Graphics.h functions are used.

We have planned to make a game in which there will be number of balloons on the display of
the screen. Which we will fill with the red or any other colour. Then we will be using a square
which can be moved with the arrow keys. And the balloon lying in its focus on pressing
any(input specified) key, the balloon will be made to change its colour and will turn it into the
similar colour of that of background, which will appear like balloon is shot.

2.2 Programming

3.2.1 Different functions used in the project:-

void draw_balloon(int ,int ):

This function is used for drawing a balloon. In this function we first use setcolor and setfillstyle
which set the color red and also filling style.
After this we are using fillellipse for drawing the ballon and line for drawing the thread.

void draw_burst ( int x, int y ):

This function is used for making the image of bursting of balloon.

void draw_bow(int x, int y):

This function is used for drawing the bow. In this, we are using setcolor, setlinestyle for setting
the color and style of the line.

After that we are using line and arc functions for drawing the bow.

void draw_arrow(int x, int y):

This function is used for drawing the arrow. In which we are using linerel for drawing the arrow
by considering the relative position of each

line.

function :
# include "graphics.h"
# include "conio.h"
# include "stdio.h"
# include "stdlib.h"
# include "dos.h"
#define ARROW_SIZE 7
#define BALLOON_SIZE 3

int flag_arrow=0,flag_balloon=1,count_arrow=6,count_balloon=10;
void *balloon,*bow,*arrow,*burst;
void *clear_balloon,*clear_burst;
void draw_balloon(int ,int );
void draw_burst ( int x, int y );
void draw_bow(int x,int y);
void draw_arrow(int x, int y);
void shoot(int *x, int *y);
int testkeys();
void fly(int *x, int *y);
void start();
void main()/
{
int gmode = DETECT, gdriver , area ;
initgraph ( &gmode, &gdriver, "c:\tc\bgi\ " ) ;
setbkcolor(1);
start();
int maxx = getmaxx() ;
int maxy = getmaxy() ;
int p=400,q=300,m=100,n=100,x=m,y=n,key,score=0,finish=0,level=1,l_flag=1;
char score1[5],ch,cnt_ball[5],char_level[2];

rectangle ( 0, 0, maxx, maxy - 10 ) ;

draw_burst(200,300);
area=imagesize(0,0,32,24);
burst=malloc(area);
getimage(200-16,300-12,200+16,300+12,burst);
putimage(200-16,300-12,burst,XOR_PUT);

draw_balloon(p,q);

area=imagesize(p-4*BALLOON_SIZE,q-
5*BALLOON_SIZE,p+4*BALLOON_SIZE,q+7*BALLOON_SIZE);
balloon=malloc(area);

getimage(p-4*BALLOON_SIZE,q-
5*BALLOON_SIZE,p+4*BALLOON_SIZE,q+7*BALLOON_SIZE,balloon);
putimage(p-4*BALLOON_SIZE, q-5*BALLOON_SIZE, balloon, COPY_PUT);

draw_arrow(x ,y );
area = imagesize(x, y-ARROW_SIZE, x+(6*ARROW_SIZE), y+ARROW_SIZE);
arrow=malloc(area);
getimage(x, y-ARROW_SIZE, x+(6*ARROW_SIZE), y+ARROW_SIZE,arrow);
putimage(x, y-ARROW_SIZE,arrow,XOR_PUT);

draw_bow(x,y);
area=imagesize(x+25,y-65,x+66,y+65);
bow=malloc(area);
getimage(x+25,y-65,x+66,y+65,bow);

if ( balloon == NULL || burst == NULL || bow == NULL )


{
printf( "Insufficient memory... Press any key " ) ;
getch() ;
closegraph() ;
restorecrtmode() ;
exit( 0 ) ;
}

while (!finish)
{
settextstyle(8,0,1);
setusercharsize(4,4,3,3);
outtextxy(getmaxx()/2-100,5,"LEVEL : ");
itoa(level,char_level,10);
setfillstyle(0,0);
bar(getmaxx()/2+40,15,getmaxx()/2+70,45);
outtextxy(getmaxx()/2+50,5,char_level);

rectangle(5,360,250,460);

if( flag_balloon && count_balloon>0 )


fly( &p, &q );
else
{
q = 400;
flag_balloon = 1;
}

if( kbhit() )
{
key = testkeys();
if(key==77)
flag_arrow = 1;
}

if( key == 27 )
break;
if (key == 80 &&!flag_arrow)
{
x=125;
putimage(x,y-65,bow,XOR_PUT);
if(y<300)
y+=25;
putimage(x,y-65,bow,XOR_PUT);
draw_bow(x-25,y);
key=0;
}
if (key == 72 &&!flag_arrow)
{
x=125;
putimage(x,y-65,bow,XOR_PUT);
if(y>70)
y-=25;
putimage(x,y-65,bow,XOR_PUT);
draw_bow(x-25,y);
key=0;
}
if(count_arrow > 0 && count_balloon > 0)
{
if(score==100 && l_flag==1)
{
level=2;
count_balloon=8;
count_arrow=6;
l_flag=2;
}
if(score==180 && l_flag==2)
{
level=3;
count_balloon=6;
count_arrow=6;
l_flag=0;
}
if( key == 77 || flag_arrow)
{
shoot(&x,&y);
draw_bow(m,y);
if(x>(p-12) && x<(p+12) && y>(q-15) && y<(q+25))
{
putimage(p-16,q-12,burst,COPY_PUT);
sound(1500);
delay(800);
nosound();
putimage(p-16,q-12,burst,XOR_PUT);
count_balloon--;
settextstyle(10,0,1);
setusercharsize(30,70,20,70);
outtextxy(20,380,"BALLOONS LEFT:");
setfillstyle(0,0);
bar(200,370,230,400);
itoa(count_balloon,cnt_ball,10);
outtextxy(200,380,cnt_ball);
flag_balloon=0;
score+=20;
itoa(score,score1,10);
setfillstyle(0,0);
bar(190,getmaxy()-50,230,getmaxy()-30);
setcolor(RED);
outtextxy(20,getmaxy()-50,"SCORE : ");
outtextxy(190,getmaxy()-50,score1);
}

key=0;
}
}
else
{
clearviewport();
setbkcolor(9);
setcolor(10);
settextstyle(4,0,7);
setusercharsize(120,50,120,40);
outtextxy(getmaxx()/2-220,getmaxy()/2-180,"GAME OVER");

settextstyle(8,0,1);
setusercharsize(50,60,40,50);
if(count_arrow<=0)
outtextxy(getmaxx()/2-100,getmaxy()/2-70,"NO MORE ARROWS");

if(count_balloon<=0)
outtextxy(getmaxx()/2-120,getmaxy()/2-70,"NO MORE BALLOONS");

outtextxy(getmaxx()/2-120,getmaxy()/2-20,"YOUR SCORE IS : ");


itoa(score,score1,10);
outtextxy(getmaxx()/2+150,getmaxy()/2-20,score1);

if(level==1)
outtextxy(getmaxx()/2-220,getmaxy()/2+20,"YOU REQUIRE TO PRACTICE
MORE");
if(level==2)
outtextxy(getmaxx()/2-70,getmaxy()/2+20,"WELL PLAYED");
if(level==3)
outtextxy(getmaxx()/2-220,getmaxy()/2+20,"YOU ARE AN EFFICIENT
SHOOTER");

outtextxy(getmaxx()/2-30,getmaxy()/2+50,"(Q)UIT");

settextstyle(1,0,1);
setusercharsize(30,65,30,60);
while( getch() != 'q');
finish=1;
break;
}
}
free(bow);
free(arrow);
free(balloon);
closegraph();
}

void draw_balloon(int x,int y)


{
setcolor(RED);
setfillstyle(1,RED);
fillellipse(x,y,3*BALLOON_SIZE,4*BALLOON_SIZE);
line(x,y+4*BALLOON_SIZE,x,y+6*BALLOON_SIZE);
}

void draw_burst ( int x, int y )


{
setlinestyle(0,0,1);
line ( x - 16, y - 12, x - 10, y - 2 ) ;
line ( x - 10, y - 2, x - 16, y ) ;
line ( x - 16, y, x - 10, y + 2 ) ;
line ( x - 10, y + 2, x - 16, y + 12 ) ;

line ( x - 16, y + 12, x - 6, y + 2 ) ;


line ( x - 6, y + 2, x, y + 12 ) ;
line ( x, y + 12, x + 6, y + 2 ) ;
line ( x + 6, y + 2, x + 16, y + 12 ) ;

line ( x - 16, y - 12, x - 6, y - 2 ) ;


line ( x - 6, y - 2, x, y - 12 ) ;
line ( x, y - 12, x + 6, y - 2 ) ;
line ( x + 6, y - 2, x + 16, y - 12 ) ;

line ( x + 16, y - 12, x + 10, y - 2 ) ;


line ( x + 10, y - 2, x + 16, y ) ;
line ( x + 16, y, x + 10, y + 2 ) ;
line ( x + 10, y + 2, x + 16, y + 12 ) ;

void draw_bow(int x,int y)


{
setcolor(RED);
setlinestyle(0,0,1);
line(x+32,y-49,x+32,y+49);
setlinestyle(0,0,3);
arc(x,y,300,60,60);
arc(x+34,y-56,100,220,6);
arc(x+34,y+56,140,260,6);
}

void shoot(int *x, int *y)


{
char cnt_arrow[5];
putimage(*x, *y-ARROW_SIZE, arrow, COPY_PUT);
delay(3);
putimage(*x, *y-ARROW_SIZE, arrow, XOR_PUT);
*x+=ARROW_SIZE;

if (*x>590)
{
*x=155;
flag_arrow=0;
count_arrow--;
settextstyle(10,0,1);
setusercharsize(30,70,20,70);
outtextxy(20,400,"ARROWS LEFT :");
setfillstyle(0,WHITE);
bar(200,400,220,425);
itoa(count_arrow,cnt_arrow,10);
outtextxy(200,400,cnt_arrow);
}

}
void draw_arrow(int x, int y)
{
setlinestyle(0,0,2);
moveto(x, y);
linerel(6*ARROW_SIZE, 0);
linerel(-2*ARROW_SIZE, -1*ARROW_SIZE+1);
linerel(0, 2*ARROW_SIZE-1);
linerel(2*ARROW_SIZE, -1*ARROW_SIZE);
}

int testkeys()
{
union REGS ii, oo ;
ii.h.ah = 0 ;
int86 ( 22, &ii, &oo ) ;

if ( oo.h.al )
return ( oo.h.al ) ;
else
return ( oo.h.ah ) ;
}

void fly(int *x, int *y)


{
int x1;
putimage(*x-4*BALLOON_SIZE, *y-5*BALLOON_SIZE, balloon, COPY_PUT);
delay(20);
char cnt_ball[5];
putimage(*x-4*BALLOON_SIZE, *y-5*BALLOON_SIZE, balloon, XOR_PUT);
*y-=BALLOON_SIZE;

if(*y<= 20)
{
*y=400;
x1=450+rand()%150;
*x=x1;
count_balloon--;
settextstyle(10,0,1);
setusercharsize(30,70,20,70);
outtextxy(20,380,"BALLOONS LEFT:");
setfillstyle(0,0);
bar(200,370,230,400);
itoa(count_balloon,cnt_ball,10);
outtextxy(200,380,cnt_ball);
}
}

void start()
{
setbkcolor(0);
settextstyle(7,0,0);
outtextxy(10,400," PRESS ANY KEY TO CONTINUE....");
settextstyle(1,0,0);
setcolor(4);
setusercharsize(25,15,20,4);
outtextxy(85,120,"BALLOON SHOOTING");
float octave[7] = { 130.81, 146.83, 164.81, 174.61, 196, 220, 246.94};
while( !kbhit() )
{
sound( octave[ random(7) ]*4 );
delay(300);
}
nosound();
getch();
clearviewport();
rectangle(1,1,638,478);
settextstyle(3,0,1);
setusercharsize(50,30,50,30);
outtextxy(150,10,"INSTRUCTIONS");
setbkcolor(LIGHTBLUE);
settextstyle(1,0,1);
setusercharsize(40,70,20,20);
outtextxy(10,70,"1. You can play three levels.");
outtextxy(10,110,"2. You can move the bow UP and DOWN with the help of arrow
keys.");
outtextxy(10,150,"3. Press right arrow key to shoot the arrow.");
outtextxy(10,190,"4. You score 20 points every time you shoot the balloon.");
outtextxy(10,230,"5. First level has 6 arrows and 10 balloons.");
outtextxy(10,270,"6. You require to score 100 points to enter the second level.");
outtextxy(10,310,"7. Second level has 6 arrows and 8 balloons.");
outtextxy(10,350,"8. You require to score 200 points to enter the third level.");
outtextxy(10,390,"9. Third level has 6 arrows and 6 balloons.");
settextstyle(7,0,1);
outtextxy(150,430,"PRESS ANY KEY TO CONITINUE");

getch();
setusercharsize(1,1,1,1);
settextstyle(0,0,0);
setbkcolor(YELLOW);
clearviewport();
}

2.3 Requirements to run the application

Software: The software side of our project is coded in C.

Game Clock: In-game movement will be controlled by different loops which makes the
balloon's movement in a clock.

Game Controls: On pressing the key stroke there is bursting of balloon.


3.0. Code-Implementation

void draw_balloon(int ,int ):

This function is used for drawing a balloon. In this function we first use setcolor and setfillstyle
which set the color red and also filling style.

After this we are using fillellipse for drawing the ballon and line for drawing the thread.

void draw_burst ( int x, int y ):

This function is used for making the image of bursting of balloon.

void draw_bow(int x, int y):

This function is used for drawing the bow. In this, we are using setcolor, setlinestyle for setting
the color and style of the line.
After that we are using line and arc functions for drawing the bow.

void draw_arrow(int x, int y):

This function is used for drawing the arrow. In which we are using linerel for drawing the arrow
by considering the relative position of each

line.

Basic functions from code:

1) Moving balloons :
void main()
{
int gdriver = DETECT,gmode;
int x=100,y=100,i,col=0;
initgraph(&gdriver,&gmode,"C:\\TC\\BGI");
while(!kbhit())
{
setcolor(15);
for(i=0;i<4;i++)
{

ellipse(x,y,0,360,10,20);
line(x,y+20,x,y+50);
x=x+20;
}
delay(1000);
col++;
if(col>=600)
col=0;
cleardevice();

}
getch();
}

2) Arrow /Bow :
void main()
{
int gdriver = DETECT,gmode;
int x=100,y=100,i,col=0;
initgraph(&gdriver,&gmode,"C:\\TC\\BGI");
setcolor(RED);
setlinestyle(0,0,1);
line(60,70,60,80);
setlinestyle(0,0,3);
arc(30,50,300,60,60);
arc(64,6,100,220,6);
arc(64,106,140,260,6);
getch();
}

4.0 Program’s Structure Analyzing and GUI Constructing


5.0 LIMITATIONS
To start with graphics programming, Turbo C is a good choice. Even though DOS has its own
limitations,  it is having a large number of  useful functions and is easy to program. To
implement graphics algorithms,  To give graphical display of statistics, To view signals from any
source, we can use C graphics. Here  is  a article to start programming  with  Turbo  C. ‘Run and
Learn’ is  our   method.   We  have  used source codes throughout the explanations. Just  execute 
them to understand what is happening. Turbo C has a good collection of graphics libraries. If you
know the basics of C, you can easily learn graphics programming.

6.0 Conclusion

Our project is a simple balloon shooting game programmed in C graphics. The game will
require software programming in C graphics. When completed our game will be connected to a
PC and take game input from the keyboard and display the graphic results on a PC monitor. We
are given with some balloons and we have to pop up those balloons by shooting them with
arrow.The game logic will consist of number of balloons on the display of the screen. Which we
will fill with the red or any other colour. Then we will be using a square which can be moved
with the arrow keys. And the balloon lying in its focus on pressing any(input specified) key, the
balloon will be made to change its colour and will turn it into the similar colour of that of
background, which will appear like balloon is shot. .This game is developed with the help of
turbo c compiler.

9.0 Future Scope

1. Start as early as possible, many of our design decisions and game parameters were done in a
hurried fashion and thuswere not as well thought out.

2. Set milestones
TABLE OF CONTENTS
1. Chapter 1 :Introduction........................................
1.1)Background...............................................
1.2)History.......................................................
1.3) Problem Stament......................................

2. Chapter 2:Software and hardware requirements


2.1)Method and design approach....................
2.2)programming............................................
2.3)Requirements to run the application.........

3. Chapter 3:Code implementation..........................

4. Chapter 4:Program structure analysis.................

5. Chapter 5:Limitations............................................

6. Chapter 6:Conclusion.............................................

7. Chapter 7:Future scope.........................................

8. Chapter 8:Bibliography.........................................
so as to be able to keep track of what is being done and what is not being done.

3. When coding the software side, for each module, plan out the code-details of that module
before actually coding it. Knowing what the module is supposed to do is not as effective as
knowing how to build it when building it.

4. Get as much experience with VHDL as possible, so as to save effort on the graphical
component of the game.

5. Be sure to leave adequate time for testing and integration.

6. The future of game is to improve the graphics and give more of realistic touch

8.0 BIBLIOGRAPHY

http://www.sourcecodesworld.com/source/show.asp?ScriptID=785
http://onecore.net/turbo-c-graphics-programming.htm
Book Graphics Programming in Turbo C 2.0 BY EZZEL BEN

http://www.sourcecodeonline.com/list?
q=source_code_of_balloon_shooting_game
Purpose and overview of project report

The purpose of the project was to develop a simple balloon shooting game by the use of c
graphics .This game is developed with the help of turbo c compiler .

We are given with some balloons and we have to pop up those balloons by shooting them with
arrow.
DESIGN APPROACH

In this game we used various functions in built functions like

1.Initgraph

2.Graphdriver

3. Graphmode

4.Path driver

5.Line function

6.Setcolor

7.Malloc

8.Getimage

9.Putimage

10.Delay
Initgraph:
Initgraph initializes the graphics system by loading a graphics driver from disk (or validating a
registered driver) then putting the system in to graphics mode.

Initgraph also resets all graphics settings (color, palette, current position, viewport, etc.) to their
defaults, then resets graphresult to 0.

Graphdriver:
Integer that specifies the graphics driver to be used. You can give graphdriver a value using a
constant of the graphics_drivers enumeration type.

Graphmode:
Integer that specifies the initial graphics mode (unless *graphdriver = DETECT). If *graphdriver
= DETECT, initgraph sets *graphmode to the highest resolution available for the detected driver.
You can give *graphmode a value using a constant of the graphics_modes enumeration type.
Pathdriver:
Specifies the directory path where initgraph looks for graphics drivers (*.BGI) first.

Line function:
line function is used to draw a line from a point(x1,y1) to point(x2,y2) i.e. (x1,y1) and (x2,y2)
are end points of the line.

Declaration :- void line(int x1, int y1, int x2, int y2)

Setcolor:
Setcolor function is used to change the current drawing color.e.g. setcolor(RED) or setcolor(4)
changes the current drawing color to RED.

Default drawing color is white.


Kbhit:
kbhit function is used to determine if a key has been pressed or not.

To use kbhit function in your program you should include the header file "conio.h".

If a key has been pressed then it returns a non zero value otherwise returns zero.

Declaration : int kbhit();


Malloc:
Void * malloc(size_t bytes)

Allocates a block of size bytes of memory returning a pointer to the beginning of the block.

The contents of the newly allocated block is not initialized remaining with indeterminate values.

Parameter-size of the memory block in bytes.

Getimage:
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);

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:
putimage function outputs a bit image onto the screen.

Declaration:- void putimage(int left, int top, void *ptr, int op);

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.

You might also like