Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
PhoneGap By Example

You're reading from   PhoneGap By Example Use PhoneGap to apply web development skills and learn variety of cross-platform mobile applications

Arrow left icon
Product type Paperback
Published in Aug 2015
Publisher
ISBN-13 9781785285318
Length 368 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (12) Chapters Close

Preface 1. Installing and Configuring PhoneGap FREE CHAPTER 2. Setting Up a Project Structure with Sencha Touch 3. Easy Work with Device – Your First PhoneGap Application "Travelly" 4. Integrating the Travelly Application with Custom Service 5. Crazy Bubbles - Your First HTML5 Mobile Game 6. Share Your Crazy Bubbles Game Result on Social Networks 7. Building a Real-time Communication Application – Pumpidu 8. Building "Imaginary" – An Application with Instagram-like Image Filters 9. Testing the PhoneGap Application 10. Releasing and Maintaining the Application Index

Implementing the game over screen


Before sharing the game results, we should implement the game over scenario. In our case, it is probably an expensive operation. We should check all the possible moves on the stage. If there are no moves a user can make to clear the next set of color bubbles, we should notify the user that the game is finished and show the share dialog box to him. So, let's develop an algorithm to check the possible moves.

I will separate the logic into two different scenarios:

  • When we check vertical identity

  • When we check horizontal identity

For both scenarios, the logic is pretty much the same. Just the x and y coordinates should change in the calculations.

The vertical scenario

In the following image, you can see all the possible positions of bubbles with the same color:

Here, you can see nine different possible combinations. I displayed only three same color bubbles in each combination, because it is enough to detect the possible successful move.

Let's look at combinations from...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime