Android: Game Programming

Extend your game development skills by harnessing the power of Android SDK

Android: Game Programming

John Horton, Raul Portales

Extend your game development skills by harnessing the power of Android SDK
Mapt Subscription
FREE
$29.99/m after trial
eBook
$49.00
RRP $69.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$49.00
$29.99p/m after trial
RRP $69.99
Subscription
eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781787128583
Paperback1089 pages

Book Description

Gaming has historically been a strong driver of technology, whether we’re talking about hardware or software performance, the variety of input methods, or graphics support and the Android game platform is no different. Android is a mature, yet still growing, platform that many game developers have embraced as it provides tools, APIs, and services to help bootstrap Android projects and ensure their success, many of which are specially designed to help game developers.

Since Android uses one of the most popular programming languages, Java, as the primary language to build apps of all types, you will start this course by first obtaining a solid grasp of the Java language and its foundation APIs. This will improve your chances of succeeding as an Android app developer. We will show you how to get your Android development environment set up and you will soon have your first working game.

The course covers all the aspects of game development through various engrossing and insightful game projects. You will learn all about frame-by-frame animations and resource animations using a space shooter game, create beautiful and responsive menus and dialogs, and explore the different options to play sound effects and music in Android. You will also learn the basics of creating a particle system and will see how to use the Leonids library.

By the end of the course, you will be able to configure and use Google Play Services on the developer console and port your game to the big screen.

This Learning Path combines some of the best that Packt has to offer in one complete, curated package. It includes content from the following Packt products:

Table of Contents

Chapter 1: Why Java, Android, and Games?
Is this book for me?
Why build games to learn to program?
Why Android and Java?
Setting up our development environment
Summary
Chapter 2: Getting Started with Android
Our first game project
Exploring Android Studio
Using the Android Studio visual designer
Structuring our code for Android
Our first look at Java
Building and installing our game
Self-test questions
Summary
Chapter 3: Speaking Java – Your First Game
Java syntax
Storing data and using it with variables
Expressing yourself in Java
Math game – asking a question
Decisions in Java
Math game – getting and checking the answer
Self-test questions
Summary
Chapter 4: Discovering Loops and Methods
Looping with loops
Methods
Enhancing our math game
Finishing touches
Self-test questions
Summary
Chapter 5: Gaming and Java Essentials
Java arrays – an array of variables
Timing with threads
Beeps n buzzes – Android sound
Life after destruction – persistence
The memory game
Self-test questions
Summary
Chapter 6: OOP – Using Other People's Hard Work
What is OOP?
Our first class and first object
Encapsulation
Inheritance
Polymorphism
More about OOP and classes
Self-test questions
Summary
Chapter 7: Retro Squash Game
Drawing with Android Canvas
Android Canvas demo app
Detecting touches on the screen
Preparing to make the retro squash game
The four implementation phases in detail
Self-test questions
Summary
Chapter 8: The Snake Game
Game design
The coordinate system
The code structure
Animation, sprite sheets, and the Snake home screen
Implementing the Snake game activity
Enhancing the game
Self-test questions
Summary
Chapter 9: Making Your Game the Next Big Thing
How to publish your app
Marketing your app
Adding leaderboards and achievements
What next?
Self-test questions
Summary
Chapter 10: Player 1 UP
A closer look at the games
Setting up your development environment
Summary
Chapter 11: Tappy Defender – First Step
Planning the first game
Building the home screen
Coding the game loop
The PlayerShip object
Drawing the scene
Deploying the game
Summary
Chapter 12: Tappy Defender – Taking Flight
Controlling the spaceship
Building the enemies
The thrill of flight – scrolling the background
Things that go bump – collision detection
Summary
Chapter 13: Tappy Defender – Going Home
Displaying a HUD
Implementing the rules
Ending the game
Adding sound FX
Adding persistence
Iteration
The finished game
Summary
Chapter 14: Platformer – Upgrading the Game Engine
The game
Upgrading the game engine
Summary
Chapter 15: Platformer – Bob, Beeps, and Bumps
The SoundManager class
Introducing Bob
Multiphase collision detection
Player input
Animating Bob
Summary
Chapter 16: Platformer – Guns, Life, Money, and the Enemy
Ready aim fire
Summary
Chapter 17: Platformer – Putting It All Together
Bullet collision detection
Adding some fire tiles
Eye candy
Summary
Chapter 18: Asteroids at 60 FPS with OpenGL ES 2
Asteroids simulator
Introducing OpenGL ES 2
Preparing OpenGL ES 2
Building an OpenGL-friendly, GameObject super class
The spaceship
Drawing at 60 + FPS
Summary
Chapter 19: Move and Draw with OpenGL ES 2
Drawing a static game border
Twinkling stars
Bringing the spaceship to life
Rapid fire bullets
Reusing existing classes
Drawing and moving the asteroids
Scores and the HUD
Summary
Chapter 20: Things That Go Bump – Part II
Planning for collision detection
Performing the checks
Precise collision detection with the border
Precise collision detection with an asteroid
Finishing touches
Summary
Chapter 21: Setting Up the Project
The right tool for the right game
The project – YASS (Yet Another Space Shooter)
Game architecture
Putting everything together
Moving forward with the example
Good practices for game developers
Summary
Chapter 22: Managing User Input
The InputController base class
The most basic virtual keypad
Creating a virtual joystick
Physical controllers
Sensors and InputControllers
Selecting control modes
Summary
Chapter 23: Into the Draw Thread
Using GameView
Improving DrawThread
Sprites
Adding a frames-per-second (fps) counter
Spawning enemies – the GameController
Occlusion culling
Parallax backgrounds
Layers
Summary
Chapter 24: Collision Detection
Detecting collisions
Rectangular bodies
Circular bodies
Mixed collision detection
Summary
Chapter 25: Particle Systems
General concepts
Making good particle systems
One shot
Emitters
Summary
Chapter 26: Sound FX and Music
SoundManager
Sound FX
Playing music
Enabling and disabling music and sound FX
Disabling system sounds
Summary
Chapter 27: Menus and Dialogs
Custom fonts
Working with backgrounds
The GameFragment
Custom dialogs
Designing for multiple screen sizes
Summary
Chapter 28: The Animation Framework
Updating BaseFragment
AnimationDrawable
View animation
Property animation
Summary
Chapter 29: Integrating Google Play Services
Setting up the developer console
Setting up the code
Achievements
Leaderboards
Opening the Play Games UI
Other features of Google Play services
Summary
Chapter 30: To the Big Screen
Project configuration
Testing for Android TV
Declaring a TV Activity
Providing a home screen banner
Declaring it as a game
Reviewing the manifest
Showing controller instructions
Beyond this book
Summary

What You Will Learn

  • Set up an efficient, professional game development environment in Android Studio
  • Explore object-oriented programming (OOP) and design scalable, reliable, and well-written Java games or apps on almost any Android device
  • Build simple to advanced game engines for different types of game, with cool features such as sprite sheet character animation and scrolling parallax backgrounds
  • Implement basic and advanced collision detection mechanics
  • Process multitouch screen input effectively and efficiently
  • Implement a flexible and advanced game engine that uses OpenGL ES 2 to ensure fast, smooth frame rates
  • Use animations and particle systems to provide a rich experience
  • Create beautiful, responsive, and reusable UIs by taking advantage of the Android SDK
  • Integrate Google Play Services to provide achievements and leaderboards to the players

Authors

Table of Contents

Chapter 1: Why Java, Android, and Games?
Is this book for me?
Why build games to learn to program?
Why Android and Java?
Setting up our development environment
Summary
Chapter 2: Getting Started with Android
Our first game project
Exploring Android Studio
Using the Android Studio visual designer
Structuring our code for Android
Our first look at Java
Building and installing our game
Self-test questions
Summary
Chapter 3: Speaking Java – Your First Game
Java syntax
Storing data and using it with variables
Expressing yourself in Java
Math game – asking a question
Decisions in Java
Math game – getting and checking the answer
Self-test questions
Summary
Chapter 4: Discovering Loops and Methods
Looping with loops
Methods
Enhancing our math game
Finishing touches
Self-test questions
Summary
Chapter 5: Gaming and Java Essentials
Java arrays – an array of variables
Timing with threads
Beeps n buzzes – Android sound
Life after destruction – persistence
The memory game
Self-test questions
Summary
Chapter 6: OOP – Using Other People's Hard Work
What is OOP?
Our first class and first object
Encapsulation
Inheritance
Polymorphism
More about OOP and classes
Self-test questions
Summary
Chapter 7: Retro Squash Game
Drawing with Android Canvas
Android Canvas demo app
Detecting touches on the screen
Preparing to make the retro squash game
The four implementation phases in detail
Self-test questions
Summary
Chapter 8: The Snake Game
Game design
The coordinate system
The code structure
Animation, sprite sheets, and the Snake home screen
Implementing the Snake game activity
Enhancing the game
Self-test questions
Summary
Chapter 9: Making Your Game the Next Big Thing
How to publish your app
Marketing your app
Adding leaderboards and achievements
What next?
Self-test questions
Summary
Chapter 10: Player 1 UP
A closer look at the games
Setting up your development environment
Summary
Chapter 11: Tappy Defender – First Step
Planning the first game
Building the home screen
Coding the game loop
The PlayerShip object
Drawing the scene
Deploying the game
Summary
Chapter 12: Tappy Defender – Taking Flight
Controlling the spaceship
Building the enemies
The thrill of flight – scrolling the background
Things that go bump – collision detection
Summary
Chapter 13: Tappy Defender – Going Home
Displaying a HUD
Implementing the rules
Ending the game
Adding sound FX
Adding persistence
Iteration
The finished game
Summary
Chapter 14: Platformer – Upgrading the Game Engine
The game
Upgrading the game engine
Summary
Chapter 15: Platformer – Bob, Beeps, and Bumps
The SoundManager class
Introducing Bob
Multiphase collision detection
Player input
Animating Bob
Summary
Chapter 16: Platformer – Guns, Life, Money, and the Enemy
Ready aim fire
Summary
Chapter 17: Platformer – Putting It All Together
Bullet collision detection
Adding some fire tiles
Eye candy
Summary
Chapter 18: Asteroids at 60 FPS with OpenGL ES 2
Asteroids simulator
Introducing OpenGL ES 2
Preparing OpenGL ES 2
Building an OpenGL-friendly, GameObject super class
The spaceship
Drawing at 60 + FPS
Summary
Chapter 19: Move and Draw with OpenGL ES 2
Drawing a static game border
Twinkling stars
Bringing the spaceship to life
Rapid fire bullets
Reusing existing classes
Drawing and moving the asteroids
Scores and the HUD
Summary
Chapter 20: Things That Go Bump – Part II
Planning for collision detection
Performing the checks
Precise collision detection with the border
Precise collision detection with an asteroid
Finishing touches
Summary
Chapter 21: Setting Up the Project
The right tool for the right game
The project – YASS (Yet Another Space Shooter)
Game architecture
Putting everything together
Moving forward with the example
Good practices for game developers
Summary
Chapter 22: Managing User Input
The InputController base class
The most basic virtual keypad
Creating a virtual joystick
Physical controllers
Sensors and InputControllers
Selecting control modes
Summary
Chapter 23: Into the Draw Thread
Using GameView
Improving DrawThread
Sprites
Adding a frames-per-second (fps) counter
Spawning enemies – the GameController
Occlusion culling
Parallax backgrounds
Layers
Summary
Chapter 24: Collision Detection
Detecting collisions
Rectangular bodies
Circular bodies
Mixed collision detection
Summary
Chapter 25: Particle Systems
General concepts
Making good particle systems
One shot
Emitters
Summary
Chapter 26: Sound FX and Music
SoundManager
Sound FX
Playing music
Enabling and disabling music and sound FX
Disabling system sounds
Summary
Chapter 27: Menus and Dialogs
Custom fonts
Working with backgrounds
The GameFragment
Custom dialogs
Designing for multiple screen sizes
Summary
Chapter 28: The Animation Framework
Updating BaseFragment
AnimationDrawable
View animation
Property animation
Summary
Chapter 29: Integrating Google Play Services
Setting up the developer console
Setting up the code
Achievements
Leaderboards
Opening the Play Games UI
Other features of Google Play services
Summary
Chapter 30: To the Big Screen
Project configuration
Testing for Android TV
Declaring a TV Activity
Providing a home screen banner
Declaring it as a game
Reviewing the manifest
Showing controller instructions
Beyond this book
Summary

Book Details

ISBN 139781787128583
Paperback1089 pages
Read More

Read More Reviews