-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools.pde
61 lines (53 loc) · 1.77 KB
/
tools.pde
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
float spreadRate = 0.12; // Spread Rate
void setPrevWorld()
{
for(int i = 0; i < noc; i++)
{
for(int j = 0; j < noc; j++)
{
for(int k = 0; k < noc; k++)
{
Pold[i][j][k] = Pnew[i][j][k];
}
}
}
}
void pause() // Pause Function
{
m_isRunning = !m_isRunning;
}
void spread(int x, int y, int z) // Spread Calculation
{
int locPressure = Pold[x][y][z];
int[] lossPressure = { // List of Spread With Calculations
int((locPressure - Pold [(x+1)%noc] [y] [z]) * spreadRate),
int((locPressure - Pold [x] [y] [(z+1)%noc]) * spreadRate),
int((locPressure - Pold [x] [y] [(z+noc-1)%noc]) * spreadRate),
int((locPressure - Pold [(x+noc-1)%noc] [y] [z]) * spreadRate),
int((locPressure - Pold [x] [(y+1)%noc] [z]) * spreadRate),
int((locPressure - Pold [x] [(y+noc-1)%noc] [z]) * spreadRate)
};
Pnew [(x+1)%noc] [y] [z] += lossPressure[0];
Pnew [x] [y] [(z+1)%noc] += lossPressure[1];
Pnew [x] [y] [(z+noc-1)%noc] += lossPressure[2];
Pnew [(x+noc-1)%noc] [y] [z] += lossPressure[3];
Pnew [x] [(y+1)%noc] [z] += lossPressure[4];
Pnew [x] [(y+noc-1)%noc] [z] += lossPressure[5];
for(int i = 0; i < lossPressure.length; i++) // Lose the Pressure Sent to Adjacent Cubes
{
Pold[x][y][z] -= lossPressure[i];
}
}
void setBoard()
{
for(int i = 0; i < noc; i++)
{
for(int j = 0; j < noc; j++)
{
for(int k = 0; k < noc; k++)
{
type[i][j][k] = false;
}
}
}
}