-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathclouds.cpp
More file actions
164 lines (147 loc) · 4.5 KB
/
clouds.cpp
File metadata and controls
164 lines (147 loc) · 4.5 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
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
#include "clouds.h"
struct cloudData{
private:
std::vector<cloudPosition> privateCloud;
public:
void set(std::vector<cloudPosition> cloud){
privateCloud = cloud;
}
std::vector<cloudPosition> get(){
return privateCloud;
}
} allCloudData;
//Worker Functions
extern "C"
std::vector<cloudPosition> setClouds(std::vector<cloudPosition> allClouds, int x, int y, int z)
{
cloudPosition p;
p.x =x;
p.y = y;
p.z = z;
allClouds.push_back(p);
//cloudData data;
//allCloudData.set(allClouds);
return allClouds;
}
extern "C"
std::vector<cloudPosition> getClouds(){
cloudData data;
std::vector<cloudPosition> clouds = allCloudData.get();
printf("Get!\n");
return clouds;
}
extern "C"
std::vector<cloudPosition> moveAllCloudsDown(Map *map, std::vector<cloudPosition> allCloudPositions, int t)
{
int xyz = 2;
int posChange = -1;
allCloudPositions = moveClouds(map,allCloudPositions, posChange, xyz, t);
return allCloudPositions;
}
extern "C"
std::vector<cloudPosition> moveAllCloudsUp(Map *map, std::vector<cloudPosition> allCloudPositions, int t)
{
int xyz = 2;
int posChange = 1;
allCloudPositions = moveClouds(map,allCloudPositions, posChange, xyz, t);
return allCloudPositions;
}
extern "C"
std::vector<cloudPosition> moveAllCloudsOver(Map *map, std::vector<cloudPosition> allCloudPositions, int t)
{
int xyz = 1;
int posChange = 1;
std::vector<cloudPosition> movedClouds = moveClouds(map,allCloudPositions, posChange, xyz, t);
return movedClouds;
}
extern "C"
std::vector<cloudPosition> moveClouds(Map *map, std::vector<cloudPosition> clouds, int posChange, int xyz, int t)
{
std::vector<cloudPosition> cloudCopy = clouds;
std::vector<cloudPosition> returnClouds = clouds;
while (clouds.size() > 0)
{
cloudPosition p = clouds.back();
//map_set(map, p.x, p.y, p.z, 0, t); //remove cloud at current position
clouds.pop_back();
}
while (clouds.size() > 0)
{
cloudPosition p = cloudCopy.back();
if(xyz == 1){
//map_set(map, p.x + posChange, p.y, p.z, 16, t);
}
else if(xyz == 2){
//map_set(map, p.x, p.y + posChange, p.z, 16, t);
}
else if(xyz == 3){
//map_set(map, p.x, p.y, p.z + posChange, 16, t);
}
clouds.pop_back();
}
if(xyz == 1){
for(int i = 0; i < returnClouds.size(); i++){returnClouds[i].x = returnClouds[i].x + posChange;}
}
else if(xyz == 2){
for(int i = 0; i < returnClouds.size(); i++){returnClouds[i].y = returnClouds[i].y + posChange;}
}
else if(xyz == 3){
for(int i = 0; i < returnClouds.size(); i++){returnClouds[i].z = returnClouds[i].z + posChange;}
}
return returnClouds;
}
//Test Functions
extern "C"
int gotClouds(std::vector<cloudPosition> clouds){
if(clouds.size() == 0)
{
printf("Test FAILED: Clouds in Vector "); printf("%ld", clouds.size()); printf("\n");
return -1;
}
else{
printf("Test PASSED: Clouds in Vector "); printf("%ld", clouds.size()); printf("\n");
return clouds.size();
}
}
extern "C"
int isPositionChanged(std::vector<cloudPosition>startData, std::vector<cloudPosition> endData){
int test = 0;
int done = 0;
while( test < 1 && done == 0){
if (startData.size() == endData.size()){
for(int idx=0; idx<startData.size(); idx++){
if(startData[idx].x == endData[idx].x){
if(startData[idx].y == endData[idx].y){
if(startData[idx].z == endData[idx].z){
/*Point is the same;*/ }
else{ test++; }}
else{ test++; }}
else{ test++; }
}
done++;
}else {test++;}
}
if( test >= 1 )
{
/// @note Output supressed for testing function efficacy
/// printf("Test FAILED: US 2.2.4 Cloud Position Changed\n");
return -1;
}
else{
/// @note Output supressed for testing function efficacy
/// printf("Test PASSED: US 2.2.4 Cloud Position Changed\n");
return 0;
}
}
extern "C"
int isValidChar(char xyz){
if( xyz == 'x' || xyz == 'y' || xyz == 'z')
{
printf("Test PASSED: valid position char change\n");
return 0;
}
else{
printf("Test PASSED: valid position char change\n");
return -1;
}
}