Game Development Reference
In-Depth Information
And in the Animal class, you add a pair to the list if an animal encounters another penguin of the
same color or one of the two animals is a multicolored penguin:
else if (a.sheetIndex === this.sheetIndex || this.isMulticolor() ||
a.isMulticolor()) {
a.visible = false;
this.visible = false;
this.root.find(ID.pairList).addPair(this.sheetIndex);
}
For the complete example, see the PenguinPairs5 program belonging to this chapter. In the next
chapter, you add the final touches to the Penguin Pairs game, and you see a better way to separate
game generic code, such as the SpriteGameObject class or the GameStateManager class, from
game-specific code, such as the PairList class.
What You Have Learned
In this chapter, you have learned:
How to program a game object selector
How to model interactions between different kinds of game objects
How to maintain and draw the number of pairs made by the player
 
Search WWH ::




Custom Search