Android:Game Programming
上QQ阅读APP看书,第一时间看更新

Preface

Android is the fastest growing operating system, and Android devices can empower, entertain, and educate the planet. Android uses one of the most popular programming languages—Java, which is a high-performance, secure, and object-oriented language.

It is the most widespread Operating System and games are what people spend most time using on their phones. Video games have never been easier to make and distribute. Who would not want to make games for Android? And on top of this, making games is fun, addictive, and very rewarding; it can be hard to stop once you get started.

The problem comes when we reach a stumbling block because we don't know how to implement a feature, or perhaps integrate it into our game. This course will help you build simple as well as complex games from scratch using the Android SDK and all your queries and obstacles will be addressed in this journey.

Let's get rolling!

What this learning path covers

Module 1, Learning Java by Building Android Games, starts off with the Java fundamentals and their use in an Android environment to make a simple math quiz game. You will be building your very own Android UI using easy to-use tools in Android Studio. You will learn to add real-time interaction with Java threads and implement locking/handling screen rotation, pixel graphics, clicks, animation, sound FX, and many other features in your games. It also covers the advanced OOP concepts for building and deploying a graphical pong-style game. This module ends with exploring different APIs and implement advanced features such as online leaderboards and achievements using Google game services

Module 2, Android Game Programming by Example, is a whirlwind tour of as many Android 2D gaming features that can possibly be squeezed into 11 chapters. Every line of the code used to build three games of increasing difficulty is shown in the text of this module and explained in a straightforward manner. It is steadily built up to implement a flexible and advanced game engine that uses OpenGL ES 2 for fast smooth frame rates. This is achieved by starting with a simple game and gradually increasing the complexity of the three complete games built step by step. You will implementing cool features like sprite sheet character animation and scrolling parallax backgrounds and be designing and implementing genuinely challenging and playable platform game levels. You will then learn to code both basic and advanced collision detection and make the math behind 2D rotation, velocity, and collision simple. Later on you will learn how to run your game designs at 60 frames per second or better and also process multi-touch screen input. By the end of this module, you will be implementing a multitude of other game features like pickups, firing weapons, HUDs, generating and playing sound FX, scenery, level transition, high scores, and more.

Module 3, Mastering Android Game Development, will help you build a real-time game from scratch using the Android SDK. This module will make you understand the internals of a game engine and each of its components. You will learn to decide when to use each of the different ways of drawing on Android. Moving forward, you will learn to handle user inputs, from virtual joysticks to gamepads, collision detection using different techniques and discover how to optimize it for complex games. You will also learn about animations and particle system and how to implement it in your game before you finally move on to tackle the challenges faced while making it available on Google play for Android TV.

What you need for this learning path

Any recent and free version of Eclipse or Android Studio running on any of the major operating systems can use the code in this course.

Android Studio is the recommended development tool, and at time of publication, the minimum system requirements are:

For Windows:

  • Microsoft Windows 8/7/Vista/2003 (32 or 64-bit)
  • GB RAM minimum, 4 GB RAM recommended
  • 400 MB hard disk space
  • At least 1 GB for Android SDK, emulator system images, and caches
  • 1280 x 800 minimum screen resolution
  • Java Development Kit (JDK) 7
  • Optional for accelerated emulator: Intel processor with support for Intel VTx, Intel EM64T (Intel 64), and Execute Disable (XD) Bit functionality

For Mac OS X:

  • Mac OS X 10.8.5 or higher, up to 10.9 (Mavericks)
  • 2 GB RAM minimum, 4 GB RAM recommended
  • 400 MB hard disk space
  • At least 1 GB for Android SDK, emulator system images, and caches
  • 1280 x 800 minimum screen resolution
  • Java Runtime Environment (JRE) 6
  • Java Development Kit (JDK) 7
  • Optional for accelerated emulator: Intel processor with support for Intel VTx, Intel EM64T (Intel 64), and Execute Disable (XD) Bit functionality

On Mac OS, run Android Studio with Java Runtime Environment (JRE) 6 for optimized font rendering. You can then configure your project to use JDK 6 or JDK 7.

For Linux:

  • GNOME or KDE desktop
  • GNU C Library (glibc) 2.15 or later
  • 2 GB RAM minimum, 4 GB RAM recommended
  • 400 MB hard disk space
  • At least 1 GB for Android SDK, emulator system images, and caches
  • 1280 x 800 minimum screen resolution
  • Oracle Java Development Kit (JDK) 7

Tested on Ubuntu 14.04, Trusty Tahr (64-bit distribution capable of running 32-bit applications).

Who this learning path is for

If you are completely new to any one of Java, Android, or game programming, this book is for you. If you want to publish Android games for fun or for business and are not sure where to start, then this book will show you what to do, step by step from the start.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book 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 files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Android-Game-Programming. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.