Collision detection Ball

But if I put the background (cols[index]); at the top, right under the draw. and the int index=int(random(10)); under the collision. It gives an error that the index cannot be resolved to a variable.

I saw this coming

this int index=int(random(10)); must be without the int : index=int(random(10));

before setup() say int index=int(random(10));

this makes index a global variable so it is known everywhere…

1 Like

MitchMitch3? Seriously?

1 Like

Now I put the int index=int(random(10)); all the way above the setup and under the collision it won’t but it starts with a random background color which is good enough for me, otherwise I bother you for even longer. Sorry for taking so long, thank you for all the support.

1 Like

BEFORE setup:

with int:

int index=int(random(10));

without the int : index=int(random(10));