You are previewing Android Game Recipes: A Problem-Solution Approach.
O'Reilly logo
Android Game Recipes: A Problem-Solution Approach

Book Description

Android game apps are typically the most popular type of Android apps in the various Google Play, Amazon Appstore and other Android app stores. So, beyond the Android game tutorials out there, what about a day-to-day handy and complete code reference for Android game developers?

Android Game Recipes is your first, reliable game coding reference for today's Android game apps. This book provides easy to follow real world game code problems and solutions, including source code.

This book covers code recipe solutions that are common to 2D game development problems such as designing a game menu, collision detection, moving characters, moving backgrounds and more. This book also includes how to work with player input, how to add multiple levels, how to create game graphics for different screen resolution, and how to work with device sensors.

After reading and using this book, you'll have the templated code snippets, solutions and frameworks to apply to your game app design to build your game, customize it, and then sell it on the Android app stores.

What you'll learn

  • How to use this handy code reference for creating, designing, building and enhancing your game app for Android

  • What solutions are common to 2D game development problems such as:

    • Creating a game menu

    • Collision detection

    • Moving characters

    • Basic physics

  • How to master the fundamentals of OpenGL ES 2 on Android

  • How to create the best work with game graphics

  • Why is simple trajectory math important and how to use it

  • How to add multiple levels to your games for your app

  • How to store data

Who this book is for

This book is for intermediate Android developers and/or game developers looking at Android.

Table of Contents

  1. Title Page
  2. Dedication
  3. Contents at a Glance
  4. Contents
  5. About the Author
  6. About the Technical Reviewer
  7. Acknowledgments
  8. Introduction
  9. Chapter 1: Getting Started
    1. What You Will Need
    2. Skills and Experience
    3. Software Versions
    4. OpenGL ES at a Glance
    5. How Games Work
    6. Summary
  10. Chapter 2: Loading an Image
    1. 2.1 Loading an Image Using Core Android Methods
    2. 2.2 Loading an Image Using OpenGL ES
    3. 2.3 Storing Images for Different Screen Resolutions
  11. Chapter 3: The Splash Screen
    1. 3.1 Creating a Splash Screen
    2. 3.2 Loading Multiple Images During a Splash Screen
    3. 3.3 Fading In to and Out of a Splash Screen
  12. Chapter 4: The Menu Screen
    1. 4.1 Create a Two-Button Menu Screen
    2. 4.2 Wire Menu Buttons
    3. 4.3 Launch a Game Thread
    4. 4.4 Exit a Game Thread Cleanly
    5. 4.5 Swap Menu Button Images
    6. 4.6 Lock the Screen Orientation
  13. Chapter 5: Reading Player Input
    1. 5.1 Detect a Screen Touch
    2. 5.2 Detect a Screen Multi-touch
    3. 5.3 Divide the Screen into Touch Zones
    4. 5.4 Detect a Screen Swipe
    5. 5.5 Use the Device Accelerometer
  14. Chapter 6: Loading a SpriteSheet
    1. 6.1 Use a Sprite Sheet
    2. 6.2 Access Images in the Sprite Sheet
    3. 6.3 Change Sprite Sheet Frames
    4. 6.4 Animate Images from a Sprite Sheet
  15. Chapter 7: Scrolling a Background
    1. 7.1 Load the Background Image
    2. 7.2 Scroll the Background Horizontally
    3. 7.3 Scroll the Background Vertically
  16. Chapter 8: Scrolling Multiple Backgrounds
    1. 8.1 Load Two Background Images
    2. 8.2 Scroll Two Background Images
    3. 8.3 Scroll Two Background Images at Different Speeds
  17. Chapter 9: Syncing the Background to Character Movement
    1. 9.1 Scroll the Background in Two Directions
    2. 9.2 Move the Background in Response to User Input
  18. Chapter 10: Building a Level Using Tiles
    1. 10.1 Load Tiles from a Sprite Sheet
    2. 10.2 Create a Level from Tiles
  19. Chapter 11: Moving a Character
    1. 11.1 Move a Character in Four Directions
    2. 11.2 Move a Character at Different Speeds
    3. 11.3 Animate a Character When It Moves
  20. Chapter 12: Moving an Enemy
    1. 12.1 Load Enemies to Predetermined Locations
    2. 12.2 Load Enemies to Random Locations
    3. 12.3 Move Enemies Along a Path
  21. Chapter 13: Moving a Character with Obstacles
    1. 13.1 Jump Between Platforms
    2. 13.2 Move up Steps
  22. Chapter 14: Firing Weapons
    1. 14.1 Wire a “Fire” Button
    2. 14.2 Animate a Missile
    3. 14.3 Animate a Thrown Weapon
    4. Summary
  23. Chapter 15: Collision Detection
    1. 15.1 Detect Obstacles
    2. 15.2 Detect Collisions Between Multiple Moving Objects
    3. 15.3 Change Object Trajectory
    4. 15.4 Damage Objects upon Collision and Remove Destroyed Objects
  24. Chapter 16: Keeping Score
    1. 16.1 Assign Point Values to Objects
    2. 16.2 Add and Track the Score
    3. 16.3 Write the Score to the Screen
  25. Chapter 17: Keeping Time
    1. 17.1 Track Time Within the Game
    2. 17.2 Stop the Action When the Time Expires
    3. 17.3 Stop the Timer When a Task Completes
  26. Index