forked from arter97/oop_orbit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
33 lines (27 loc) · 714 Bytes
/
Copy pathmain.cpp
File metadata and controls
33 lines (27 loc) · 714 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
#include <iostream>
#include "compatibility.h"
#include "universe.h"
int main() {
// Always flush stdout directly
setbuf(stdout, NULL);
Sun S(40, 12, 'S');
// Distance between Sun and Earth is 10
Earth E(10, 'E', &S);
Earth E2(-10, 'R', &S);
// Distance between Earth and Moon is 3
Moon M(3, 'M', &E);
Moon M2(-3, 'N', &E2);
S.Show();
for (short angle = 0;;angle += angle_diff) {
// Avoid overflow
if (angle == 360)
angle = 0;
E.Revolve(angle);
E2.Revolve(angle);
// Let the Moon circle around Earth 5 times faster
M.Revolve(angle * 5);
M2.Revolve(angle * 5);
sleep(sleep_duration);
}
return 0;
}