Sorry about the inadequate label, I'm not even really sure what to call my question(!).
The broad issue is this: if you're iterating through a list of actors and you want to do certain things to each depending on certain variables, and you also need to get some user input for each actor, how do you control the flow?
Specifically, I might have any number of spaceships in the air at once. I also have a function, named checkColonizeAbility(), that checks to see if the ship can colonize a planet (depending on how far away it is, etc.). If the ship can colonize, then the player is prompted to decide whether or not to colonize that planet or move on. There's no problem when there is only one ship that is able to colonize at a time, but if there are more than one, how do I control the flow so that the user can give input for each one?
In code, I've got more or less the following:
void nextTurn()
{
int i; //each i represents a pointer to a ship actor contained in an array
for(i = 0; i < shipCount; i++)
{
if(checkColonizeAbility(i) == 1)
{
colonize();
}
}
}
In other words, I need to somehow suspend execution of the for loop while the player is asked whether or not he wants to colonize. Then, after somehow saving the player's decision, I need to proceed to the next ship (the next i). Does my question make sense? And does anyone have a clue as to how to proceed?
Thanks in advance!