-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroad.cpp
More file actions
76 lines (62 loc) · 1.78 KB
/
Copy pathroad.cpp
File metadata and controls
76 lines (62 loc) · 1.78 KB
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
#include "road.h"
//general road
RoadNormal::RoadNormal(const double& r_width)//һ���·
{
Rwidth = r_width;
left_boundary = SWIDTH / 2.0 - Rwidth;
right_boundary = SWIDTH / 2.0 + Rwidth;
}
//showing road
void RoadNormal::showRoad()
{
setlinestyle(PS_SOLID, 4);
setlinecolor(BLACK);
line(left_boundary, 0.0, left_boundary, SHEIGHT);
line(right_boundary, 0.0, right_boundary, SHEIGHT);
}
//double lane
RoadDoubleLane::RoadDoubleLane(const double& r_width) {
Rwidth = r_width;
left_boundary = SWIDTH / 2.0 - Rwidth;
right_boundary = SWIDTH / 2.0 + Rwidth;
}
void RoadDoubleLane::showRoad() {
setlinestyle(PS_SOLID, 4);
setlinecolor(BLACK);
line(left_boundary, 0.0, left_boundary, SHEIGHT);
line(right_boundary, 0.0, right_boundary, SHEIGHT);
setlinestyle(PS_DASH, 4);
line(SWIDTH / 2.0, 0.0, SWIDTH / 2.0, SHEIGHT);
}
//crosswalk road
RoadCrosswalk::RoadCrosswalk(const double& r_width) {
Rwidth = r_width;
left_boundary = SWIDTH / 2.0 - Rwidth;
right_boundary = SWIDTH / 2.0 + Rwidth;
mid_line = SHEIGHT / 2.0 - 200.0;
up_line = mid_line - Rwidth / 2.0;
down_line = mid_line + Rwidth / 2.0;
}
//display for crosswalk road
void RoadCrosswalk::showRoad() {
setlinestyle(PS_SOLID, 4);
setlinecolor(BLACK);
line(left_boundary, 0.0, left_boundary, SHEIGHT);
line(right_boundary, 0.0, right_boundary, SHEIGHT);
line(left_boundary, up_line, right_boundary, up_line);
line(left_boundary, down_line, right_boundary, down_line);
int i = 0;
while (true)
{
double up_bound = up_line + disRec;
double down_bound = down_line - disRec;
double left_bound = left_boundary + disRec * (1 + 2 * i);
double right_bound = left_boundary + disRec * 2 * (i + 1);
if (right_bound >= right_boundary)
{
break;
}
rectangle(left_bound, up_bound, right_bound, down_bound);
i++;
}
}