forked from tanus786/CP-Codes-HackOctober-Fest-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CARCG.C
92 lines (69 loc) · 2.01 KB
/
CARCG.C
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// C program to draw a moving car. This
// program run in gcc compiler having
// graphics.h library installed
#include <graphics.h>
#include <stdio.h>
// Function to draw moving car
void draw_moving_car(void) {
int i, j = 0, gd = DETECT, gm;
// Passed three arguments to initgraph
// function to initialize graphics mode
initgraph(&gd, &gm, "C:\\TURBOC3\\BGI");
for (i = 0; i <= 420; i = i + 10) {
// Set color of car as red
setcolor(RED);
// Thease lines for bonnet and
// body of car
line(0 + i, 300, 210 + i, 300);
line(50 + i, 300, 75 + i, 270);
line(75 + i, 270, 150 + i, 270);
line(150 + i, 270, 165 + i, 300);
line(0 + i, 300, 0 + i, 330);
line(210 + i, 300, 210 + i, 330);
// For left wheel of car
circle(65 + i, 330, 15);
circle(65 + i, 330, 2);
// For right wheel of car
circle(145 + i, 330, 15);
circle(145 + i, 330, 2);
// Line left of left wheel
line(0 + i, 330, 50 + i, 330);
// Line middle of both wheel
line(80 + i, 330, 130 + i, 330);
// Line right of right wheel
line(210 + i, 330, 160 + i, 330);
delay(100);
// To erase previous drawn car, draw
// the whole car at same position
// but color using black
//setcolor(BLACK);
// Lines for bonnet and body of car
//line(0 + i, 300, 210 + i, 300);
//line(50 + i, 300, 75 + i, 270);
//line(75 + i, 270, 150 + i, 270);
//line(150 + i, 270, 165 + i, 300);
//line(0 + i, 300, 0 + i, 330);
//line(210 + i, 300, 210 + i, 330);
// For left wheel of car
//circle(65 + i, 330, 15);
//circle(65 + i, 330, 2);
// For right wheel of car
//circle(145 + i, 330, 15);
//circle(145 + i, 330, 2);
// Line left of left wheel
//line(0 + i, 330, 50 + i, 330);
// Line middle of both wheel
//line(80 + i, 330, 130 + i, 330);
// Line right of right wheel
//line(210 + i, 330, 160 + i, 330);
Cleardevice();
}
getch();
closegraph();
}
// Driver code
int main()
{
draw_moving_car();
return 0;
}