Hi,
I'm looking through the reference and still can't find a handy way to do this:
Basically, I've an array of 8 numbers.
I've got an if clause that states if
i is true, check if abs(i-4) is false.
As an example: if array[7] is true, check if array[abs(7-4)], which is array[3] is false.
This works except that once the result of the subtraction goes past 0, it's out of bounds. I want it to loop back to 7. Eg, the sequence, if counting, would go: 3,2,1,0,7,6,5,4, etc...
I can think of a few long winded ways of doing this, but I'm trying to avoid doing these as they may lead to a big mess of code further down the road.
The section of the code this is relavant to is:
Code:
for (int i=0; i < 8; i++) {
if (layerOne[i] == true) {
if (layerTwo[i*2] == true) {
if (layerOne[abs(i-4)] == false) {
checkOne = true; // theres 3 pixels in a row, starting at currColor, but not going the other way.
ellipse(x,y,5,5);
}
}
}
Thanks.