Skip to content

Commit fc5acae

Browse files
committed
Fix out-of-bounds error when selecting too many balls.
When setting the number to e.g. 15, the index overran.
1 parent aeab64e commit fc5acae

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

resources/rgbscripts/ballscolors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ var testAlgo;
207207
var yDirection = (Math.random() * 2) - 1; // and random directions
208208
var xDirection = (Math.random() * 2) - 1;
209209
algo.direction[i] = [yDirection, xDirection];
210-
algo.colour[i] = colorPalette.collection[algo.colorIndex[i]][1];
210+
algo.colour[i] = colorPalette.collection[algo.colorIndex[i % algo.colorIndex.length]][1];
211211
}
212212
algo.initialized = true;
213213
return;

0 commit comments

Comments
 (0)