#include <iostream.h>
#include <conio.h>
#include <ctype.h>
# include <process.h>
# include <dos.h>
# include <stdlib.h>
# include <graphics.h>
# include <stdio.h>
# define NULL 0
# define YES 1
# define NO 0
#define ESC 0x1b
int
int
GraphMode;
*/
double AspectRatio;
int
MaxXX, MaxYY;
int
MaxColors;
int
ErrorCode;
*/
*/
*/
// To display the bricks (in square box) and paddles in rectangle form and
main
()
{
union REGS ii, oo ;
case 'F' :
case 'f' :
speed = 10 ;
}
/* draw the four layer of bricks, the paddle and the ball */
rectangle ( 0, 0, MaxX, MaxY - 12 ) ;
bricks() ;
rectangle ( MidX - 25, MaxY - 7 - 12, MidX + 25, MaxY - 12 ) ;
floodfill ( MidX, MaxY - 1 - 12, 12 ) ;
circle ( MidX, MaxY - 13 - 12, 12 ) ;
floodfill ( MidX, MaxY - 10 - 12, 12 ) ;
/* image of the paddle and the ball is stored into allocated memory */
getimage ( MidX - 12, MaxY - 7 - 12 - 12 + 1, MidX + 12, MaxY - 8 - 12,
m1 ) ;
getimage ( MidX - 25, MaxY - 7 - 12, MidX + 25, MaxY - 1 - 12, m2 ) ;
while ( 1 )
{
flag = 0 ;
else
{
if ( BallY > 20 )
{
max = 30 ;
layer = 2 ;
}
else
{
if ( BallY > 10 )
{
max
= 20 ;
layer
=1;
}
else
{
max
= 10 ;
layer
=0;
}
}
}
}
/* check whether
there is a brick to the left of the ball */
if ( bri[layer]
[ ( BallX - i + 10 ) / 32 ] == 0 )
{
BallX
= BallX - i ;
flag
=1;
break
;
}
}
/* restore the
image of the ball at the old coordinates */
putimage ( OldX,
OldY, m1, OR_PUT ) ;
/* delay for
fewseconds*/
delay ( speed ) ;
/* carry on moving
the ball */
continue ;
}
}
if ( ( BallX + 10 ) / 32 == 0 )
line ( 0, 0, 0, 50 ) ; /* redraw
left boundary */
/* introduce delay
for fewseconds */
delay ( speed ) ;
/* saveing current
x and y coordinates of the ball */
OldX = BallX ;
OldY = BallY ;
/* update ballx
and bally to move the ball in correct direction */
BallX = BallX + dx
;
BallY = BallY +
dy ;
}
";
outtextxy ( MidX,
closegraph() ;
restorecrtmode() ;
closegraph();
/* Close the graphics mode */
Initialize();
/* Intialize the graphics mode */
setbkcolor(4);
SayGoodbye();
/* Display the That's all Folks message */
/* Return the system to text mode
closegraph();
*/
exit ( 0 ) ;
}
}
bell ( 2 ) ;
closegraph() ;
restorecrtmode() ;
exit ( 0 ) ;
}
exit ( 0 ) ;
}
closegraph();
Initialize();
mode
SayGoodbye();
*/
closegraph();
*/
return(0);
}
screen()
{
int i, j, lx = 0, ly = 0, ch ;
rectangle(1,1,600,195);
setbkcolor(4);
/* set the textstyle for displaying instruction */
changetextstyle ( DEFAULT_FONT, HORIZ_DIR, 0 ) ;
outtextxy ( 150, 55, "
Instructions
");
closegraph();
initgraph ( &graphdriver, &graphmode, "c:\tc\bgi " ) ;
rectangle(2,2,620,195);
setbkcolor(4);
/* display the main menu */
while ( 1 )
{
changetextstyle(4,HORIZ_DIR,5);
outtextxy ( 60, 8, "Options Available:" ) ;
outtextxy ( 150, 55, "Play ( P )" ) ;
outtextxy ( 150, 125, "Exit ( E )" ) ;
ch = 0 ;
if ( ch == 'P' )
break ;
if (ch == 'E')
exit ( 0 ) ;
/* store
clearviewport() ;
/* This function draws bricks at the start of the game.There are four
layers of
the bricks */
bricks()
{
int i, j, lx = 0, ly = 0 ;
{
for ( j = 0 ; j < 30 ; j++ ) /* 20 columns */
{
/* draw a brick at appropriate coordinates */
rectangle ( lx, ly, lx + 20, ly + 7 ) ;
floodfill ( lx + 1, ly + 1, 2 ) ;
lx = lx + 32 ;
}
lx = 0 ;
ly = ly + 10 ;
}
}
setcolor ( BLACK ) ;
rectangle ( b * 32, l * 10, ( b * 32 ) + 20 , ( l * 10 ) + 7 ) ;
rectangle ( b * 32 + 1, l * 10, ( b * 32 ) + 20 - 1, ( l * 10 ) + 7 - 1 )
;
rectangle ( b * 32 + 2, l * 10, ( b * 32 ) + 20 - 2, ( l * 10 ) + 7 - 2 )
;
rectangle ( b * 32 + 3, l * 10, ( b * 32 ) + 20 - 3, ( l * 10 ) + 7 - 3 )
;
rectangle ( b * 32 + 4, l * 10, ( b * 32 ) + 20 - 4, ( l * 10 ) + 7 - 4 )
;
rectangle ( b * 32 + 5, l * 10, ( b * 32 ) + 20 - 5, ( l * 10 ) + 7 - 5 )
;
rectangle ( b * 32 + 6, l * 10, ( b * 32 ) + 20 - 6, ( l * 10 ) + 7 - 6 )
;
setcolor ( CGA_YELLOW ) ;
}
switch ( m_no )
{
case 1 :
for ( i = 0 ; i < 6 ; i++ )
{
sound ( wave[i] * 1 ) ;
delay ( 30 ) ;
}
nosound() ;
break ;
case 2 :
for ( i = 0 ; i < 15 ; i++ )
{
n = random ( 6 ) ;
sound ( wave[n] * 2 ) ;
delay ( 100 ) ;
}
nosound() ;
break ;
case 3 :
while ( !kbhit() )
{
n = random ( 6 ) ;
sound ( wave[n] * 2 ) ;
delay ( 100 ) ;
}
nosound() ;
break ;
case 4 :
for ( i = 5 ; i >= 0 ; i-- )
{
sound ( wave[i] * 4 ) ;
delay ( 15 ) ;
}
nosound() ;
break ;
case 5 :
sound ( wave[2] * 5 ) ;
delay ( 50 ) ;
nosound() ;
}
}
/*
*/
/*
/*
/*
*/
void Initialize(void)
*/
{
int xasp, yasp;
ratio*/
GraphDriver = DETECT;
*/
/* Request auto-detection
getpalette( &palette );
*/
MaxColors = getmaxcolor() + 1;
MaxXX = getmaxx();
MaxYY = getmaxy();
*/
/*
*/
/*
/*
*/
void SayGoodbye(void)
{
struct viewporttype viewinfo;
*/
int h, w;
getviewsettings( &viewinfo );
*/
h = viewinfo.bottom - viewinfo.top;
w = viewinfo.right - viewinfo.left;
outtextxy( w/2, h/2, "That's all, folks!" );
cleardevice();
*/
/*
*/
/*
MAINWINDOW: Establish the main window for the demo and set
*/
/*
/*
*/
cleardevice();
*/
setcolor( MaxColors - 1 );
*/
*/
/*
*/
/*
/*
*/
setcolor( MaxColors - 1 );
*/
*/
/*
*/
/*
/*
viewport.
*/
/*
*/
void DrawBorder(void)
{
struct viewporttype vp;
setcolor( MaxColors - 1 );
*/
getviewsettings( &vp );
rectangle( 0, 0, vp.right-vp.left, vp.bottom-vp.top );
/*
*/
/*
/*
/*
*/
graphresult();
*/
/* check result
/* if error occured
closegraph();
printf(" Graphics System Error: %s
", grapherrormsg( ErrorCode ) );
exit( 1 );
}
}
/* The main function body of main screen which displays the main screen
creating the opening screen display */
mainscreen()
{
int maxx, maxy, in, area;
TO ");
outtextxy(220,100," BRICKS");
changetextstyle(7, HORIZ_DIR, 3);
bell(3);
outtextxy(110, 150, "Press any key to continue...");
fflush(stdin);
getch();
closegraph();