/
RADARTES.CPP
133 lines (89 loc) · 2.27 KB
/
RADARTES.CPP
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
/*
Test for radar screen
ver 0.0
*/
# include <dos.h>
# include <math.h>
# include "radarscr.h"
# include "stdio.h"
# include "gate.h"
# include "eiflist.h"
# include "table.h"
# include "flightpa.h"
# include "landmars.h"
int main () {
textmode (ATC_TEXT_MODE);
clrscr();
Position::MaxX = 30;
Position::MaxY = 30;
char pid;
Position::MaxX = 30;
Position::MaxY = 30;
RadarScreen *r;
Landmarks l;
Traffic t;
Plane *p1;
Gate g (Position (0, 10), 1, D90);
Gate g1 (Position (0, 0), 2, D45);
Gate g2 (Position (10, 0), 3, D0);
Gate g3 (Position (MAX_X, MAX_Y), 4, D225);
// Gate g4 (Position (10, 0), 4, D0);
Airport a1 (Position (5, 5), 1, Heading (D90));
Airport a2 (Position (10, 12), 2, Heading (D45));
Beacon b1 (Position (7,13), 1);
Beacon b2 (Position (1,1), 2);
FlightPath fp (Position (MIN_FIELD_X, MIN_FIELD_Y),
Position (MAX_FIELD_X, MAX_FIELD_Y));
FlightPath fp1 (Position (MIN_FIELD_X, MAX_FIELD_Y),
Position (MAX_FIELD_X, MIN_FIELD_Y));
FlightPath fp2 (Position (10, 1), Position (10, MAX_FIELD_Y));
int i;
l.AddAirport (&a1);
l.AddAirport (&a2);
l.AddBeacon (&b1);
l.AddBeacon (&b2);
l.AddGate (&g);
l.AddGate (&g1);
l.AddGate (&g2);
l.AddGate (&g3);
// l.AddGate (&g4);
l.AddFlightPath (&fp);
l.AddFlightPath (&fp1);
l.AddFlightPath (&fp2);
r = new RadarScreen (&l);
Boolean Crashed = False;
r->Refresh();
pid = t.NewId();
p1 = new Plane (pid, g.NewPlaneCoords(), Prop, &g1);
t.NewAirborne (p1);
p1 = new Plane (t.NewId(), g1.NewPlaneCoords(), Jet, &g);
t.NewAirborne (p1);
p1 = new Plane (t.NewId(), g2.NewPlaneCoords(), Jet, &g);
t.NewAirborne (p1);
r->DisplayPlanes (&t);
for (i = 0; i < 34; i++) {
delay (500);
if (i == 17) {
t.SearchAirborne ('a');
t.FoundAirborne() -> AlterTargHeading (D270, AntiClockwise);
t.SearchAirborne ('b');
t.FoundAirborne() -> MakeCircle (AntiClockwise);
}
r->UnDisplayPlanes (&t);
if (i % 2 == 0) {
t.StepJets();
} else {
t.StepAll();
}
r->DisplayPlanes (&t);
if (!Crashed && t.Crashed ()) {
cout << '\a';
Crashed = True;
}
}
textmode (C80);
_setcursortype (_NORMALCURSOR);
clrscr();
return 0;
}
/**/