-
Notifications
You must be signed in to change notification settings - Fork 10
/
car.c
182 lines (137 loc) · 3.31 KB
/
car.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#include<iostream>
#include<conio.h>
#include<graphics.h>
void flood(int x, int y, int new_col, int old_col)
{
if (getpixel(x, y) == old_col)
{
putpixel(x, y, new_col);
flood(x + 1, y, new_col, old_col);
flood(x - 1, y, new_col, old_col);
flood(x, y + 1, new_col, old_col);
flood(x, y - 1, new_col, old_col);
}
}
int main()
{
int gd=DETECT,gm,i,p=0;
initgraph(&gd,&gm,NULL);
i=0;
//Frame
line(0,0,0,500);
line(639,0,639,500);
line(0,0,639,0);
line(0,500,639,500);
//Car Body
line(50,370,95,370);
arc(110,370,0,180,20);
line(125,370,225,370);
arc(240,370,0,180,20);
line(255,370,300,370);
line(300,370,300,350);
line(300,350,240,330);
line(240,330,200,300);
line(110,300,202,300);
line(110,300,80,330);
line(80,330,50,340);
line(50,340,50,370);
//Window
line(165+i,305,165+i,330);
line(165+i,330,230+i,330);
line(230+i,330,195+i,305);
line(195+i,305,165+i,305);
flood(166,306,15,0);
line(160+i,305,160+i,330);
line(160+i,330,95+i,330);
line(95+i,330,120+i,305);
line(120+i,305,160+i,305);
//Wheel
circle(110+i,370,17);
circle(240+i,370,17);
//Road
line(0,420,639,420);
line(0,330,80,330);
line(240,330,639,330);
rectangle(0,360,40,370);
rectangle(350,360,400,370);
rectangle(450,360,500,370);
rectangle(550,360,600,370);
//land boundary
line(0,200,370,200);
line(580,200,639,200);
//Mountain
line(0,200,200,100);
line(200,100,370,200);
line(285,150,480,100);
line(480,100,639,200);
//Sun
circle(250,50,25);
//River
setcolor(1);
line(0,215,200,215);
arc(200,246,0,90,30);
arc(200,246,270,360,30);
line(150,276,200,276);
arc(150,276,270,360,20);
line(0,295,150,295);
//Cloud
setcolor(15);
arc(639,60,90,180,50);
arc(600,85,90,180,30);
arc(610,85,180,270,40);
line(605,124,639,124);
//House
line(350,230,400,150);
line(400,150,450,230);
line(400,150,550,150);
line(550,150,600,230);
line(450,230,600,230);
line(352,228,352,320);
rectangle(450,230,600,320);
line(352,320,450,320);
rectangle(500,250,550,320);
circle(400,200,15);
rectangle(370,250,420,290);
line(395,250,395,290);
//Car Colouring
flood(111,301,4,0);
flood(121,306,15,0);
flood(1,361,15,0);
flood(351,361,15,0);
flood(451,361,15,0);
flood(551,361,15,0);
//Road Colouring
flood(1,331,8,0);
//Mountain Colouring
flood(150,150,6,0);
flood(350,150,6,0);
//Sun Colouring
flood(251,51,14,0);
//Sky Colouring
flood(1,1,11,0);
//River Colouring
flood(1,216,1,0);
//Cloud Colouring
flood(601,61,15,0);
//Land Colouring
flood(1,421,10,0);
flood(1,201,10,0);
//House Colour
flood(410,151,4,0);
flood(410,231,12,0);
flood(451,231,12,0);
flood(401,201,14,0);
flood(371,251,6,0);
flood(396,251,6,0);
flood(501,251,6,0);
//Bird
setcolor(0);
arc(400,50,0,90,10);
arc(420,50,90,180,10);
arc(440,50,0,90,10);
arc(460,50,90,180,10);
arc(430,70,0,90,10);
arc(450,70,90,180,10);
getch();
return 0;
}