File tree
Expand file treeCollapse file tree1 file changed
+6
-5
lines changed Assets/Patterns/7. Double Buffer/Cave
Expand file treeCollapse file tree1 file changed
+6
-5
lines changed Original file line number | Diff line number | Diff line change |
---|
@@ -40,6 +40,9 @@ void Start()
|
40 | 40 | bufferOld = new int[GRID_SIZE, GRID_SIZE];
|
41 | 41 | bufferNew = new int[GRID_SIZE, GRID_SIZE];
|
42 | 42 |
|
| 43 | +//To get the same random numbers each time we run the script |
| 44 | +Random.InitState(100); |
| 45 | + |
43 | 46 | //Init the old values so we can calculate the new values
|
44 | 47 | for (int x = 0; x < GRID_SIZE; x++)
|
45 | 48 | {
|
@@ -79,14 +82,12 @@ private IEnumerator SimulateCavePattern()
|
79 | 82 | GenerateAndDisplayTexture(bufferNew);
|
80 | 83 |
|
81 | 84 | //Swap the pointers to the buffers
|
82 |
| -int[,] temp = bufferOld; |
83 |
| - |
84 |
| -bufferOld = bufferNew; |
85 |
| - |
86 |
| -bufferNew = temp; |
| 85 | +(bufferOld, bufferNew) = (bufferNew, bufferOld); |
87 | 86 |
|
88 | 87 | yield return new WaitForSeconds(PAUSE_TIME);
|
89 | 88 | }
|
| 89 | + |
| 90 | +Debug.Log("Simulation completed!"); |
90 | 91 | }
|
91 | 92 |
|
92 | 93 |
|
|
You can’t perform that action at this time.
0 commit comments