Game Development Reference
In-Depth Information
Start
Setup
Wait for
gesture
Yes
Turns
remaining?
End game
No
User selects coin
Set first coin
selected
Set no coin
selected
No
Is a coin
selected?
Yes
No
Yes
Animate
removal
Are there
matches?
Yes
User select
same coin?
No
Update
CoinGame
Add new coins
Animate switch
Figure 4-7. Coin Sorter life cycle
Figure 4-7 shows the flow of the application for a single game. After setup, the application waits for
the user to select a coin. If a first coin is not selected, the application simply keeps track that the
coin was selected and goes back to waiting for the user. When the user selects a coin a second
time, the application checks whether the coin just selected is the same coin as the first one selected.
If so, the application unselects the coin. This allows the user to change his mind. If the user selects
a different coin, the game state updates by modifying the CoinGame object, and animations
are created, showing the two coins trading places. When the coin-swapping animation is done,
the application checks whether any matches exist. If so, it animates their removal and updates
CoinGame with new coins to replace those just removed. Because adding new coins could create
additional matches, the application checks again for matches. This process could theoretically go on
forever, but in practice it does not. Eventually, there will be no matches to remove.
When there are no matches, the application checks whether the user has any turns remaining. If the
user does, it goes back to waiting for the user's input. If the user does not, the game is over.
 
 
Search WWH ::




Custom Search