Where we
left off was the second else branch, which corresponds to the situation where a second tile
is clicked that isn??™t the already-flipped tile. In that case, two tiles are logically flipped at this
point. So, we need to determine whether the player found a match. First, we block further
player clicks by setting playerProcessClicks to false. Next, we flip over the tile that was just
clicked. Third, we compare their values from the playerTileValues array. If they match, we
begin the explosion of the tiles by starting off with the first animation frame and ensuring we
are incrementing the frame number each iteration. Finally, we set an interval to fire every
tenth of a second and call the cyclePlayerExplosion() method.
If the tiles don??™t match, we let the player see them both for half a second by setting a timeout.
Remember, the difference between a timeout and an interval is that a timeout fires once
CHAPTER 8 n DWR FOR FUN AND PROFIT (A DWR GAME!) 437
after a defined period of time, while an interval fires continuously on a specified schedule.
Once the timeout elapses, it calls unFlip(), which you recall sets playerProcessClicks to true,
so at that point the player can make another selection.
Pages:
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749