Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Android Game Programming By Example

You're reading from   Android Game Programming By Example Harness the power of the Android SDK by building three immersive and captivating games

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher
ISBN-13 9781785280122
Length 388 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
John Horton John Horton
Author Profile Icon John Horton
John Horton
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Player 1 UP FREE CHAPTER 2. Tappy Defender – First Step 3. Tappy Defender – Taking Flight 4. Tappy Defender – Going Home 5. Platformer – Upgrading the Game Engine 6. Platformer – Bob, Beeps, and Bumps 7. Platformer – Guns, Life, Money, and the Enemy 8. Platformer – Putting It All Together 9. Asteroids at 60 FPS with OpenGL ES 2 10. Move and Draw with OpenGL ES 2 11. Things That Go Bump – Part II Index

Setting up your development environment

All the code in this book and the download bundle will work in your favorite Android IDE. However, I found the latest version of Android Studio exceptionally friendly to use and the code was written and tested in it as well.

If you don't currently use Android Studio, I encourage you to give it a try. Here is a quick overview of how to get up and running quickly. This guide includes steps to install the Java JDK in case you are completely new to Android development.

Tip

If you already have your preferred development environment ready to go then jump straight to Chapter 2, Tappy Defender – First Step.

The first thing we need to do is prepare your PC to develop for Android using Java. Fortunately, this is made quite simple for us.

Tip

If you are learning on Mac or Linux everything in this book will still work. The next two tutorials have Windows-specific instructions and screenshots. However, it shouldn't be too difficult to vary the steps slightly to suit Mac or Linux.

All we need to do is:

  1. Install the Java Development Kit (JDK), which allows us to develop in Java.
  2. Then install Android Studio to make Android development fast and easy. Android Studio uses the JDK and some other Android-specific tools that get automatically installed when we install Android Studio.

Installing the JDK

The first thing we need to do is get the latest version of the JDK. To complete this guide, perform the following instructions:

  1. We need to be on the Java website, so visit: http://www.oracle.com/technetwork/java/javase/downloads/index.html.
  2. Find the three buttons shown here and click on the one that says JDK that is highlighted in the following image. They are on the right-hand side of the web page. Then, click on the Download button under the JDK option:
    Installing the JDK
  3. You will be taken to a page that has multiple options to download the JDK. In the Product/File Description column, you need to click the option that matches your operating system. Windows, Mac, Linux, and some other less common options are all listed.
  4. A common question asked here is, do I have 32- or 64-bit windows? To find out, right-click on your My Computer icon (This PC on Windows 8), click on the Properties option, and look under the System heading at the System type entry:
    Installing the JDK
  5. Click on the somewhat hidden Accept License Agreement checkbox:
    Installing the JDK
  6. Now, click on download for your OS and type as previously determined. Wait for the download to finish.
  7. In your downloads folder, double-click on the file you just downloaded. The latest version at the time of writing for a 64-bit Windows PC was jdk-8u5-windows-x64. If you are using Mac/Linux or have a 32-bit OS, your filename will vary accordingly.
  8. In the first of several install dialogs, click on the Next button and you will see the following dialog box:
    Installing the JDK
  9. Accept the defaults shown in the previous image by clicking on Next. In the next dialog box, you can accept the default install location by clicking on Next.
  10. Next up is the last dialog of the Java installer; for this click on Close.

    Note

    The JDK is now installed. Next, we will make sure that Android Studio is able to use the JDK.

  11. Right-click on your My Computer icon (This PC on windows 8) and click on Properties | Advanced system settings | Environment Variables... | New... (under System variables, not under User variables). Now, you can see the New System Variable dialog box:
    Installing the JDK
  12. Type JAVA_HOME for Variable name: and enter C:\Program Files\Java\jdk1.8.0_05 for the Variable value: field. If you installed the JDK somewhere else, then the file path you enter in the Variable value: field will need to point to wherever you put it. Your exact file path will likely have a different ending to match the latest version of Java at the time you downloaded it.
  13. Click on OK to save your new settings.
  14. Now under System variables, click on Path and then click on the Edit... button. At the very end of the text in the Variable value: field, enter the following text to add our new variable to the file paths that Windows will use, ;JAVA_HOME. Be sure not to miss the semicolon from the beginning.
  15. Click on OK to save the updated Path variable.
  16. Now, click on OK again to clear the Advanced system settings dialog box.

The JDK is now installed on our PC.

Installing Android Studio

Without delay, let's get Android Studio installed, and then we can begin our first game project. Visit:

https://developer.android.com/sdk/index.html

  1. Click on the button labeled DOWNLOAD ANDROID STUDIO FOR WINDOWS to start the Android Studio download. This will take you to another web page with a very similar looking button to the one you just clicked on.
  2. Accept the license by checking the checkbox and commence the download by clicking the button labeled DOWNLOAD ANDROID STUDIO FOR WINDOWS and wait for the download to complete.
  3. In the folder you just downloaded Android Studio to, right-click on the android-studio-bundle-135.12465-windows.exe file and click on Run as administrator. The end of your filename will vary depending on the version of Android Studio and your operating system.
  4. When asked if you want to allow the following program from an unknown publisher to make changes to your computer, click on Yes. On the next screen, click on Next.
  5. On the screen pictured here, you can choose which users of your PC can use Android Studio. Choose which is right for you as all options will work, and then click on Next:
    Installing Android Studio
  6. In the next dialog, leave the default settings and then click on Next.
  7. On the Choose start menu folder dialog box leave the defaults and click on Install.
  8. On the Installation complete dialog, click on Finish to run Android Studio for the first time.
  9. The next dialog is for users who have already used Android Studio, so assuming you are first-time user, select the I do not have a previous version of Android Studio or I do not want to import my settings checkbox. Then click on OK:
    Installing Android Studio

That was the last piece of software we needed. We will begin to use Android Studio straight away in the next chapter.

You have been reading a chapter from
Android Game Programming By Example
Published in: Jun 2015
Publisher:
ISBN-13: 9781785280122
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
Banner background image