You are previewing The Android Game Developer's Handbook.
O'Reilly logo
The Android Game Developer's Handbook

Book Description

Discover an all in one handbook to developing immersive and cross-platform Android games

About This Book

  • Practical tips and tricks to develop powerful Android games

  • Learn to successfully implement microtransactions and monitor the performance of your game once it’s out live.

  • Integrate Google’s DIY VR tool and Google Cardboard into your games to join in on the VR revolution

  • Who This Book Is For

    This book is ideal for any game developer, with prior knowledge of developing games in Android. A good understanding of game development and a basic knowledge on Android platform application development and JAVA/C++ will be appreciated.

    What You Will Learn

  • Learn the prospects of Android in Game Development

  • Understand the Android architecture and explore platform limitation and variations

  • Explore the various approaches for Game Development using Android

  • Learn about the common mistakes and possible solutions on Android Game Development

  • Discover the top Cross Platform Game Engines and port games on different android platform

  • Optimize memory and performance of your game.

  • Familiarize yourself with different ways to earn money from Android Games

  • In Detail

    Gaming in android is an already established market and growing each day. Previously games were made for specific platforms, but this is the time of cross platform gaming with social connectivity. It requires vision of polishing, design and must follow user behavior. This book would help developers to predict and create scopes of improvement according to user behavior.

    You will begin with the guidelines and rules of game development on the Android platform followed by a brief description about the current variants of Android devices available. Next you will walk through the various tools available to develop any Android games and learn how to choose the most appropriate tools for a specific purpose.

    You will then learn JAVA game coding standard and style upon the Android SDK. Later, you would focus on creation, maintenance of Game Loop using Android SDK, common mistakes in game development and the solutions to avoid them to improve performance. We will deep dive into Shaders and learn how to optimize memory and performance for an Android Game before moving on to another important topic, testing and debugging Android Games followed by an overview about Virtual Reality and how to integrate them into Android games.

    Want to program a different way? Inside you’ll also learn Android game Development using C++ and OpenGL. Finally you would walk through the required tools to polish and finalize the game and possible integration of any third party tools or SDKs in order to monetize your game when it’s one the market!

    Style and approach

    The book follows a handbook approach, focused on current and future game development trend from every possible aspect including monetization and sustainability in the market.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. The Android Game Developer's Handbook
      1. Table of Contents
      2. The Android Game Developer's Handbook
      3. Credits
      4. About the Author
      5. About the Reviewer
      6. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why subscribe?
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Errata
          2. Piracy
          3. Questions
      8. 1. Android Game Development
        1. Android game development
          1. Features and support
          2. Challenges
          3. User experience
          4. Design constraints
        2. A game is not just an application
          1. Games versus applications
          2. Life cycle of Android application and games
          3. Performance of games and applications
          4. Memory management of games and applications
        3. Choosing the target device configuration
          1. Game scale
          2. Target audience
          3. Feature requirement
          4. Scope for portability
        4. Best practices for making an Android game
          1. Maintaining game quality
          2. Minimalistic user interface
          3. Supporting maximum resolutions
          4. Supporting maximum devices
          5. Background behavior
          6. Interruption handling
          7. Maintaining battery usage
          8. Extended support for multiple visual quality
          9. Introducing social networking and multiplayer
        5. Summary
      9. 2. Introduction to Different Android Platforms
        1. Exploring Android mobiles
        2. Exploring Android tablets
        3. Exploring Android televisions and STBs
        4. Exploring Android consoles
        5. Exploring Android watches
        6. Development insights on Android mobiles
        7. Development insights on Android tablets
        8. Development insights on Android TV and STBs
          1. UI and game design
          2. Overscan
        9. Development insights on Android consoles
        10. Development insights on Android watches
          1. Creating and setting up a wearable application
          2. Including the correct libraries in the project
          3. Hardware compatibility issues with Android versions
        11. Platform-specific specialties
          1. Android mobiles
          2. Android tablets
          3. Android televisions and STBs
          4. Android consoles
          5. Android watches
        12. Summary
      10. 3. Different Android Development Tools
        1. Android SDK
        2. Android Development Tool
        3. Android Virtual Device
          1. Configuring AVD
        4. Android Debug Bridge
          1. Using adb on an Android device
        5. Dalvik Debug Monitor Server
        6. Other tools
          1. Eclipse
          2. Hierarchy Viewer
          3. Draw 9-Patch
          4. ProGuard
          5. Asset optimization tools
            1. Full asset optimization
            2. Creating sprites
        7. Tools for testing
          1. Creating a test case
          2. Setting up your test fixture
          3. Adding test preconditions
          4. Adding test methods to verify an activity
        8. Performance profiling tools
        9. Android Studio
          1. Android project view
          2. Memory and CPU monitor
        10. Cross-platform tools
          1. Cocos2d-x
          2. Unity3D
          3. Unreal Engine
          4. PhoneGap
          5. Corona
          6. Titanium
        11. Summary
      11. 4. Android Development Style and Standards in the Industry
        1. The Android programming structure
          1. Class formation
          2. Call hierarchy
        2. Game programming specifications
          1. Gameplay programming
          2. Graphics programming
          3. Technical programming
            1. Sound programming
            2. Network programming
            3. Game tool programming
            4. Research and development programming
        3. Technical design standards
          1. Game analysis
          2. Design pattern and flow diagram
          3. Technical specification
          4. Tools and other requirements
          5. Resource analysis
          6. Testing requirements
          7. Scope analysis
          8. Risk analysis
          9. Change log
        4. Game design standards
          1. Game overview
          2. Gameplay details
          3. Game progression
          4. Storyboard and game elements
          5. Level design
          6. Artificial intelligence
          7. Art style
          8. Technical reference
          9. Change log
        5. Other styles and standards
        6. Different styles for different development engines
          1. Different programming languages
          2. Different work principles
          3. Different target platforms
        7. Industry best practices
          1. Design standards
          2. Programming standards
          3. Testing standards
        8. Summary
      12. 5. Understanding the Game Loop and Frame Rate
        1. Introduction to the game loop
          1. User input
          2. Game update
          3. State update
          4. Rendering frames
        2. Creating a sample game loop using the Android SDK
        3. Game life cycle
        4. Game update and user interface
        5. Interrupt handling
        6. General idea of a game state machine
        7. The FPS system
        8. Hardware dependency
          1. Display or rendering
          2. Memory load/unload operations
            1. Heap memory
            2. Stack memory
            3. Register memory
            4. ROM
          3. Logical operations
        9. Balance between performance and memory
        10. Controlling FPS
        11. Summary
      13. 6. Improving Performance of 2D/3D Games
        1. 2D game development constraints
          1. 2D art assets
            1. Sets of 2D art assets
            2. Same asset set for multiple resolutions
            3. Number of assets drawn on screen
            4. Use of font files
              1. Sprite font
              2. Bitmap font
              3. TrueType font
          2. 2D rendering system
          3. 2D mapping
          4. 2D physics
            1. Box2D
            2. LiquidFun
            3. Performance impact on games
          5. 2D collision detection
            1. Rectangle collision
            2. Rectangle and circle collision
            3. Circle and circle collision
            4. Performance comparison
        2. 3D game development constraints
          1. Vertices and triangles
          2. 3D transformation matrix
          3. 3D object and polygon count
          4. 3D rendering system
          5. 3D mesh
          6. Materials, shaders, and textures
            1. Textures
            2. Shaders
            3. Materials
          7. Collision detection
            1. Primitive colliders
            2. Mesh colliders
          8. Ray casting
          9. Concept of "world"
            1. Elements of the game world
            2. Light sources in the game world
            3. Cameras in the game world
        3. The rendering pipeline in Android
          1. The 2D rendering pipeline
          2. The 3D rendering pipeline
        4. Optimizing 2D assets
          1. Size optimization
          2. Data optimization
          3. Process optimization
        5. Optimizing 3D assets
          1. Limiting the polygon count
          2. Model optimization
        6. Common game development mistakes
          1. Use of non-optimized images
          2. Use of full utility third-party libraries
          3. Use of unmanaged networking connections
          4. Using substandard programming
          5. Taking a shortcut
        7. 2D/3D performance comparison
          1. Different look and feel
          2. 3D processing is way heavier than 2D processing
          3. Device configuration
            1. Processor
            2. RAM
            3. GPU
            4. Display quality
            5. Battery capacity
        8. Summary
      14. 7. Working with Shaders
        1. Introduction to shaders
          1. What is a shader?
          2. Necessity of shaders
          3. Scope of shaders
        2. How shaders work
        3. Types of shaders
          1. Pixel shaders
          2. Vertex shaders
          3. Geometry shaders
          4. Tessellation shaders
        4. Android library shaders
        5. Writing custom shaders
        6. Shaders through OpenGL
        7. Use of shaders in games
          1. Shaders in a 2D game space
          2. Shaders in a 3D game space
        8. Summary
      15. 8. Performance and Memory Optimization
        1. Fields of optimization in Android games
          1. Resource optimization
            1. Art optimization
            2. Sound optimization
            3. Data file optimization
          2. Design optimization
            1. Game design optimization
            2. Technical design optimization
          3. Memory optimization
            1. Don't create unnecessary objects during runtime
            2. Use primitive data types as far as possible
            3. Don't use unmanaged static objects
            4. Don't create unnecessary classes or interfaces
            5. Use the minimum possible abstraction
            6. Keep a check on services
            7. Optimize bitmaps
            8. Release unnecessary memory blocks
            9. Use external tools such as zipalign and ProGuard
          4. Performance optimization
            1. Using minimum objects possible per task
            2. Using minimum floating points
            3. Using fewer abstraction layers
            4. Using enhanced loops wherever possible
            5. Avoid getter/setters of variables for internal use
            6. Use static final for constants
            7. Using minimum possible inner classes
        2. Relationship between performance and memory management
        3. Memory management in Android
          1. Shared application memory
          2. Memory allocation and deallocation
          3. Application memory distribution
        4. Processing segments in Android
          1. Application priority
            1. Active process
            2. Visible process
            3. Active services
            4. Background process
            5. Void process
          2. Application services
            1. Service life cycle
          3. Resource processing
            1. Drawable resources
            2. Layout resources
            3. Color resources
            4. Menu resources
            5. Tween animation resources
            6. Other resources
        5. Different memory segments
          1. Stack memory
          2. Heap memory
          3. Register memory
        6. Importance of memory optimization
        7. Optimizing overall performance
          1. Choosing the base resolution
          2. Defining the portability range
          3. Program structure
          4. Managing the database
          5. Managing the network connection
        8. Increasing the frame rate
        9. Importance of performance optimization
        10. Common optimization mistakes
          1. Programming mistakes
          2. Design mistakes
          3. Wrong game data structure
          4. Using game services incorrectly
        11. Best optimization practices
          1. Design constraints
          2. Development optimization
          3. Data structure model
          4. Asset-using techniques
            1. Art assets
            2. Audio assets
            3. Other assets
          5. Handling cache data
        12. Summary
      16. 9. Testing Code and Debugging
        1. Android AVDs
          1. Name of the AVD
          2. AVD resolution
          3. AVD display size
          4. Android version API level
          5. Android target version
          6. CPU architecture
          7. RAM amount
          8. Hardware input options
          9. Other options
          10. Extended AVD settings
        2. Android DDMS
          1. Connecting an Android device filesystem
          2. Profiling methods
          3. Thread information monitoring
          4. Heap information monitoring
          5. Tracking memory allocation
          6. Monitoring and managing network traffic
          7. Tracking log information using Logcat
          8. Emulating device operations
        3. Android device testing and debugging
          1. Device testing
            1. Prototype testing
            2. Full or complete testing
            3. Regression testing
            4. Release testing or run testing
          2. Device debugging
            1. Use of breakpoints
        4. Monitoring the memory footprint
          1. Checking log messages
            1. Dalvik message log
            2. ART message log
          2. Checking heap updates
          3. Tracking memory allocation
          4. Checking overall memory usage
            1. Private RAM
            2. Proportional set size (PSS)
          5. Tracking memory leaks
        5. Strategic placement of different debug statements
          1. Memory allocation
          2. Tracking the object state at runtime
          3. Checking the program flow
          4. Tracking object values
        6. Exception handling in Android games
          1. Syntax
          2. Scope
            1. Null pointer exceptions
            2. Index out of bound exceptions
            3. Arithmetic exceptions
            4. Input/output exceptions
            5. Network exceptions
            6. Custom exceptions
        7. Debugging for Android while working with cross-platform engines
        8. Best testing practices
          1. Tools and APIs
          2. Testing techniques
            1. Local test
            2. Instrumented test
        9. Summary
      17. 10. Scope for Android in VR Games
        1. Understanding VR
          1. Evolution of VR
          2. Modern VR systems
          3. Use of VR
            1. Video games
            2. Education and learning
            3. Architectural design
            4. Fine arts
            5. Urban design
            6. Motion pictures
            7. Medical therapy
        2. VR in Android games
          1. History of Android VR games
          2. Technical specifications
          3. Current Android VR game industry
        3. Future of Android in VR
          1. Google Daydream
        4. Game development for VR devices
          1. VR game design
          2. VR target audience
          3. VR game development constraints
        5. Introduction to the Cardboard SDK
          1. Cardboard headset components
          2. Cardboard application working principle
          3. Upgrades and variations
        6. Basic guide to develop games with the Cardboard SDK
          1. Launching and exiting the VR game
            1. Hitting the Back button
            2. Hitting the Home button
          2. VR device adaptation
          3. Display properties
          4. In-game components
          5. Game controls
            1. Control concepts
              1. Types of controls
                1. Fuse button
                2. Visual countdown
              2. Fuse button indication
              3. Control placement
        7. VR game development through Google VR
          1. Google VR using the Android SDK
          2. Google VR using Android NDK
        8. Android VR development best practices
          1. Draw call limitations
          2. Triangle count limitations
          3. Keeping a steady FPS
          4. Overcoming overheating problems
          5. Better audio experience
          6. Setting up proper project settings
          7. Using a proper test environment
        9. Challenges with the Android VR game market
          1. Low target audience
          2. Limited game genres
          3. Long game sessions
          4. Limited device support
          5. Real-time constraints
        10. Expanded VR gaming concepts and development
        11. Summary
      18. 11. Android Game Development Using C++ and OpenGL
        1. Introduction to the Android NDK
          1. How the NDK works
            1. Native shared library
            2. Native static library
          2. Build dependency
            1. Android SDK
            2. C++ compiler
            3. Python
            4. Gradle
            5. Cygwin
            6. Java
          3. Native project build configuration
            1. Android.mk configuration
            2. Application.mk configuration
        2. C++ for games – pros and cons
          1. Advantages of using C++
            1. Universal game programming language
            2. Cross-platform portability
            3. Faster execution
            4. CPU architecture support
          2. Disadvantages of using C++
            1. High program complexity
            2. Platform-dependent compiler
            3. Manual memory management
          3. Conclusion
        3. Native code performance
        4. Rendering using OpenGL
          1. OpenGL versions
            1. OpenGL 1.x
            2. OpenGL 2.0
            3. OpenGL 3.0
            4. OpenGL 3.1
            5. Detecting and setting the OpenGL version
          2. Texture compression and OpenGL
            1. ATC
            2. PVRTC
            3. DXTC
          3. OpenGL manifest configuration
          4. Choosing the target OpenGL ES version
            1. Performance
            2. Texture support
            3. Device support
            4. Rendering feature
            5. Programming comfort
        5. Different CPU architecture support
          1. Available CPU architectures
            1. ARM
            2. x86
            3. Neon
            4. MIPS
          2. Advantages and disadvantages of integrating multiple architecture support
        6. Summary
      19. 12. Polishing Android Games
        1. Requirements for polishing
          1. Development polishing
            1. Memory optimization
            2. Performance optimization
            3. Portability
          2. Art polishing
            1. UI polishing
            2. Animation polishing
            3. Marketing graphics
          3. Design polishing
            1. Designing UX
            2. Polishing the game flow
            3. Polishing the metagame
            4. Game economy balance
            5. Game difficulty balance
        2. Play testing
          1. User gameplay difficulty levels
          2. User actions during gameplay
          3. User actions while browsing the game
          4. Whether the user is paying or not
          5. Whether the game is running smoothly
          6. Whether the user can adopt the gameplay
          7. User retention
        3. Taking care of the UX
          1. Visual effects
          2. Sound effects
            1. Theme music
            2. SFXs
          3. Transaction effects
          4. Action feedback
        4. Android-specific polishing
          1. Optimum use of hardware buttons
          2. Sticking to basic Android features and functionalities
          3. Longer background running
          4. Following Google guidelines for Play Store efficiency
        5. Game portability
          1. Support for various screen sizes
          2. Support for multiple resolutions
          3. Support for multiple hardware configurations
        6. Summary
      20. 13. Third-Party Integration, Monetization, and Services
        1. Google Play Services
          1. Google Analytics
            1. Significance
            2. Integration tips
            3. Best utilization
          2. Google IAB
            1. The Google IAB model
              1. Consumable items
              2. Non-consumable items
              3. Subscriptions
            2. Integrating Google IAB
            3. Advantages and disadvantages of Google IAB
          3. Google Leaderboard
            1. Significance
            2. Integrating Google Leaderboard
            3. Variety of leaderboards
              1. Social Leaderboard
              2. Public Leaderboard
            4. Options for storing and displaying leaderboards
          4. Push notifications
            1. Database
            2. Server
            3. Target device
            4. GCM service
              1. Workflow of the push notification system using GCM
            5. Integrating push notifications
              1. Application integration
              2. GCM setup
              3. Server setup
            6. Significance of push notifications
              1. User retention
              2. User control
              3. Knowing user behavior
              4. Alternative communication channel
        2. Multiplayer implementation
          1. Real-time multiplayer
          2. Turn-based multiplayer
          3. Single-screen real-time multiplayer
          4. Pass and play turn-based multiplayer
          5. Local network multiplayer
        3. Analytic tools
          1. Requirement of analytics tools
            1. User behavior
            2. Game crash reports
            3. Game event triggers
            4. Gameplay session timing
            5. Gameplay frequency
            6. Game balancing
            7. User retention
            8. Piracy prevention
          2. Monetization aspects of analytic tools
            1. Identify popular regions of the game
            2. Identify a user's likes and dislikes
            3. Validate and improve the metagame
            4. Track paying users
            5. Track and count advertisement display
          3. Some useful analytic tools
            1. Flurry
            2. GameAnalytics
            3. Crashlytics
            4. AppsFlyer
            5. Apsalar
            6. Mixpanel
            7. Localytics
            8. Appcelerator
        4. Android in-app purchase integration
          1. What are in-app purchases?
          2. In-app purchase options
            1. Store billing services
              1. Amazon billing services
                1. ResponseReceiver
                2. PurchasingService
                3. PurchasingListener
            2. Career billing services
          3. Types of in-app purchases
            1. Consumable items
            2. Non-consumable items
            3. Subscriptions
        5. Android in-game advertisements
          1. Requirement for advertisements
          2. Terminologies in advertisement monetization
            1. eCPM
            2. CPC/CPA
            3. CPI
            4. RPM
            5. Fillrate
          3. Types of advertisements
            1. Banner advertisements
            2. Interstitial advertisements
              1. Integration best practice
            3. Video advertisements
              1. Full length ads
              2. Short length ads
            4. In-game dynamic advertisements
        6. Monetization techniques
          1. Premium model
          2. Free model
          3. Freemium model
          4. Try-and-buy model
        7. Planning game revenue
          1. Revenue versus profit
          2. Revenue sources
            1. Advertisement revenue
            2. In-app purchase revenue
            3. Other revenue sources
          3. Regional variations of revenue plan
            1. User base variations
            2. User behavior variations
        8. User acquisition techniques
          1. Game promotion channels
            1. YouTube channels
            2. Android forums
            3. Sports forums
            4. Facebook promotion
            5. Twitter and other social platforms
          2. Game blogs and forum discussions
          3. Paid user acquisition
          4. Other techniques
        9. User retention techniques
          1. Daily bonus
          2. Leaderboards and achievements
          3. Offerwall Integration
          4. Push notifications
          5. Frequent updates
        10. Featuring Android games
          1. Creativity and uniqueness
          2. User reviews and ratings
          3. Download count
          4. Revenue amount
        11. Publishing Android games
          1. Self publishing
          2. Publishing through publishers
        12. Summary
      21. Index