We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have an array float[] positionx = new float[100]. I want to be able to add 1 to all of the values in that array from 0 to a certain variable (let's say its value is 50). I don't want to do positionx[0] = positionx[0] + 1, positionx[1] = positionx[1] + 1, and so on all the way to 50. Is there a simpler way to do it? Something like positionx[0 through X] = positionx[0 through X] + 1
Answers
for loop?
Kf
Could you give an example please? I have no idea how to use a for loop here.
Edit: I see how it could be done but wouldn't using a for loop mean adding 1 to each of them one after another? I need them all to add 1 at the same moment.
Use a for loop. Yes, they are increase one after another, but this happens so fast that it might as well happen at the same moment. Example:
This is perfect, thank you.
Importantly, it also happens before the next time that draw() refreshes the screen -- so even if it was slow (and it is blazing fast) nothing will every be drawn based only some array members in the loop being updated. It will be none or all.