-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample_code.C
More file actions
34 lines (30 loc) · 780 Bytes
/
sample_code.C
File metadata and controls
34 lines (30 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
void drawBall(int x, int y){
setcolor(12);
circle(x,y,5);
setfillstyle(SOLID_FILL, 12);
floodfill(x,y,12);
}
int main() {
int gdriver = DETECT, gmode;
int i;
initgraph(&gdriver, &gmode, "c:\\turboc3\\bgi");
clrscr();
// move in parabolic path from (10, 100) to (70, 80); (50, 20) also lies in the path
// using equation y = a[X]^2 + b[X] + c
// using equation y = (1/12)*[X]^2 - 7*[X] + (485/3)
drawBall(10, 100);
for(i = 10; i <= 70; i++){
int x = i;
// on every point of X from 10 -> 70, value of Y get updated
int y = 1/12.0*x*x - 7*x + 485/3.0; //y = (1/12)*[X]^2 - 7*[X] + (485/3)
drawBall(x,y);
delay(80);
// clrscr();
}
getch();
closegraph();
return 0;
}