Skip to main content

Bouncing Ball


Group B  

Practical 4 a  

Problem Statement : Write a C++ program to implement bouncing ball using sine wave form. Apply the concept of polymorphism.

Check Out Code Here 👇


#include<dos.h>
#include<iostream.h>
#include<graphics.h>
#include<math.h>
#include<conio.h>
int main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
float x=1,y,j=0.5,count=0.1,i;
setcolor(01);
for(int k=0;k<7;k++)
{
for(i=90;i<270;i+=10)
{
y=cos(i*3.14/180)/j;
x+=5;
circle(x,y*100+200,15);
floodfill(x,y*100+200,01);
line(0,215,800,215);
delay(50);
clrscr();
}
j+=count;
count+=0.1;
}
getch();
return 0;
}
view raw bouncing-ball hosted with ❤ by GitHub

Outputs : 






Code can get updated so also come back later to see if there is any changes. Also if there is any problem with code you can comment below. If you like it, do share with your friends.😊

Comments

Popular posts from this blog

2D Object Transformations

  Group B   Practical 4 a   Problem Statement :    Write C++ program to draw 2-D object and perform following basic transformations a) Scaling b) Translation c) Rotation. Apply the concept of operator overloading. Check Out Code Here  👇 Output : a) Scaling - b) Translation - c) Rotation - Code can get updated so also come back later to see if there is any changes. Also if there is any problem with code you can comment below. If you like it, do share with your friends.😊

OOP 4

  Object Oriented Programming Group B - Practical : 4 Problem Statement :  Write a C++ program that creates an output file, writes information to it, closes the file, open it again as an input file and read the information from the file. Check Out Code Here  👇 Code can get updated so also come back later to see if there is any changes. Also if there is any problem with code you can comment below. If you like it, do share with your friends.😊