I am having troubles in making shapes moving in random directions, with the code that i currently have they all move in the same direction and then change to another direction randomly.
Here is the code
for(int i = 0; i < 50; i++)
{
int randomMoveX = rand() % 2 + (-1);
int randomMoveY = rand() % 2 + (-1);
circleObjectArray[i].move(randomMoveX,randomMoveY);
while(randomMoveX == 0)
{
randomMoveX = rand() % 2 + (-1);
}
while(randomMoveY == 0)
{
randomMoveY = rand() % 2 + (-1);
}
cout << "randomMoveX: " << randomMoveX << endl;
cout << "randomMoveY: " << randomMoveY << endl;
}
How can i change my code to be able to do move them in random directions individually?
Thank you for your time :D