Adding AI
Adding AI in the character select screen proved to be more challenging than I expected, as I had to consider which player slots the AI should go into, and what would happen if there was AI in a player slot and that player wished to join the game, and how would the adding or removing of an AI affect the current system for selecting players?
The system I settled on consists of three functions, addAI(), removeAI(), and removeAI(int index).
- addAI() is called when a player uses up on the left stick or arcade joystick, it finds the first empty player slot and sets it as an AI, selecting a random character and confirming the selection, as the character select menu can't advance until all selections are confirmed.
- removeAI() is called when the player uses down on the left stick or arcade joystick, it finds the last AI added to the game and removes them, unconfirming their selection and changing their highlighted character to none, as the character select menu won't advance if their is a highlighted character who is unconfirmed.
- removeAI(int index) is called when input is received by a player whose spot is taken up by an AI, it removes the AI at that spot, and unconfirms their selection, but doesn't change their highlighted character to none, as the player's input suggests that they wish to be in the game.