Code:
#include <winbgim.h>
#include <stdlib.h>
#include <iostream.h>
#include <time.h>
void itBECOMESBLUE(void);
void createwalls(int,int);
void createball(void);
void createpad(void);
void moveball(void);
void movepad(void);
void eraseoldball(void);
void setlocation(void);
void gotohell(void);
void makepad(void);
char pressme;
int r=3, hitcounter=0, padcenter, oldpadcenter, ballx=320, bally=240, oldballx=ballx,
oldbally=bally, padx, gameonoff=0, leftwall, rightwall, counter, centerx=320, centery=240;
int dirx=1, diry=2, ballgox, ballgoy;
main()
{
initwindow(640,480);
createwalls(2,2);
itBECOMESBLUE();
createball();
createpad();
while(!kbhit());
while(!ismouseclick(WM_LBUTTONDBLCLK))
{
ballx = oldballx;
bally = oldbally;
eraseoldball();
itBECOMESBLUE();
moveball();
if(gameonoff==1)
goto outtaloop;
movepad();
}
outtaloop:
closegraph();
}
void createwalls(int leftwall, int rightwall)
{
setcolor(COLOR(141, 249, 136));
rectangle(leftwall,1,leftwall+1,480);
rectangle(640-rightwall,1,640-rightwall+1,480);
rectangle(leftwall,1,640-rightwall,2);
return;
}
void createball(void)
{
circle(centerx,centery,r);
return;
}
void createpad(void)
{
padcenter=centerx;
setcolor(WHITE);
rectangle(padcenter-3,460,padcenter+3,461);
return;
}
void itBECOMESBLUE(void)
{
setcolor(COLOR(20,10,250));
return;
}
void eraseoldball(void)
{
setcolor(BLACK);
circle(oldballx,oldbally,r);
return;
}
void moveball(void)
{
itBECOMESBLUE();
if(ballx==leftwall+3)
ballgox=1;
if(ballx==rightwall-3)
ballgox=0;
if(bally==4)
ballgoy=1;
if(bally==457)
{
if(padcenter+3>ballx && padcenter-3<ballx)
ballgoy=0;
counter++;
}
if(bally==450)
{
goto hell;
}
if (ballgox==1)
ballx++;
if (ballgox==0)
ballx--;
if (ballgoy==1)
bally++;
if (ballgoy==0)
bally--;
circle(ballx,bally,r);
return;
hell:
gameonoff=1;
return;
}
void movepad(void)
{
oldpadcenter=padcenter;
setcolor(BLACK);
rectangle(oldpadcenter-3,460,oldpadcenter+3,461);
padcenter=mousex();
if(padcenter<=5 || padcenter>=674)
padcenter=oldpadcenter;
setcolor(COLOR(141,249,136));
rectangle(padcenter-3,460,padcenter+3,461);
return;
}
Thanx for being so patient with reading this...