I need Ball Bouncing Graphical Program in c
Solved/Closed
Related:
- I need Ball Bouncing Graphical Program in c
- Psh4x 8 ball pool ios - Download - Sports
- Master ball cheat fire red - Guide
- Coagula program - Download - Other
- Kerbal space program download - Download - Simulation
- End it all program - Download - Cleaning and optimization
1 response
Dear Saran,
Please consider the following sample, it should be helpful to you
in the particular task:
#include<graphics.h>
#include<conio.h>
#include<alloc.h>
#include<dos.h>
#include<stdlib.h>
void *ball;
void image()
{
//ball
setcolor(RED);
setfillstyle(SOLID_FILL,RED);
fillellipse(10,10,10,10);
ball=malloc(imagesize(0,0,20,20));
getimage(0,0,20,20,ball);
cleardevice();
}
void main()
{
int gm,gd=DETECT;
initgraph(&gd,&gm,"");
int l=getmaxx()/2,r=0,t=0,b=0;
int x=1,y=1;
int s=0,key=0;
int xstep=1,ystep=1;
image();
setbkcolor(GREEN);
while(key!=27)
{
while(!kbhit()){
putimage(l,t,ball,XOR_PUT);
delay(5);
putimage(l,t,ball,XOR_PUT);
if(l>=getmaxx()||l<=0){x*=-1;sound(1000);s=0;xstep=x*(random(4)+1);ystep=y
*(random(3)+1);if(l<=0)l=0;else l=getmaxx();}
if(t>=getmaxy()||t<=0){y*=-1;sound(1000);s=0;ystep=y*(random(4)+1);xstep=x
*(random(3)+1);if(t<=0)t=0;else t=getmaxy();}
l+=x+xstep;
t+=y+ystep;
s++;
if(s==5)
{nosound();}
}
key=getch();
}
closegraph();
}
Hope that this information proves useful to you and solves the matter.
Thank you.
Please consider the following sample, it should be helpful to you
in the particular task:
#include<graphics.h>
#include<conio.h>
#include<alloc.h>
#include<dos.h>
#include<stdlib.h>
void *ball;
void image()
{
//ball
setcolor(RED);
setfillstyle(SOLID_FILL,RED);
fillellipse(10,10,10,10);
ball=malloc(imagesize(0,0,20,20));
getimage(0,0,20,20,ball);
cleardevice();
}
void main()
{
int gm,gd=DETECT;
initgraph(&gd,&gm,"");
int l=getmaxx()/2,r=0,t=0,b=0;
int x=1,y=1;
int s=0,key=0;
int xstep=1,ystep=1;
image();
setbkcolor(GREEN);
while(key!=27)
{
while(!kbhit()){
putimage(l,t,ball,XOR_PUT);
delay(5);
putimage(l,t,ball,XOR_PUT);
if(l>=getmaxx()||l<=0){x*=-1;sound(1000);s=0;xstep=x*(random(4)+1);ystep=y
*(random(3)+1);if(l<=0)l=0;else l=getmaxx();}
if(t>=getmaxy()||t<=0){y*=-1;sound(1000);s=0;ystep=y*(random(4)+1);xstep=x
*(random(3)+1);if(t<=0)t=0;else t=getmaxy();}
l+=x+xstep;
t+=y+ystep;
s++;
if(s==5)
{nosound();}
}
key=getch();
}
closegraph();
}
Hope that this information proves useful to you and solves the matter.
Thank you.
Apr 13, 2010 at 10:23 AM
Jan 23, 2013 at 01:20 PM
Feb 11, 2013 at 12:56 AM
Jun 24, 2013 at 02:06 PM