-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbody.cpp
More file actions
53 lines (49 loc) · 1.61 KB
/
body.cpp
File metadata and controls
53 lines (49 loc) · 1.61 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
#include <string>
#include <iostream>
#include "vec3.cpp"
#include <list>
class body {
public:
body() {
this->name = "";
this->radius = 0;
this->mass = 0;
this->pos = vec3();
this->vel = vec3();
this->trailSz = 2;
this->color = vec3(0, 0, 0);
}
body(std::string name, double radius, double mass, vec3 pos, vec3 vel, int trailSz, vec3 color) {
this->name = name;
this->radius = radius;
this->mass = mass;
this->pos = pos;
this->vel = vel;
this->trailSz = trailSz;
this->color = color;
}
std::string name;
double radius;
double mass;
vec3 pos;
vec3 vel;
int trailSz;
vec3 color;
std::list<int> trailX = std::list<int>();
std::list<int> trailY = std::list<int>();
int* trailgrow(int x, int y) {
if(trailX.front() == x && trailY.front() == y) {
return new int[2]{0,0};
}
trailX.push_front(x);
trailY.push_front(y);
int retx=0; int rety=0;
if (trailX.size() > trailSz) {
retx = trailX.back();
rety = trailY.back();
trailX.pop_back();
trailY.pop_back();
}
return new int[2]{retx, rety};
}
};