Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Android Game Programming by Example

You're reading from  Android Game Programming by Example

Product type Book
Published in Jun 2015
Publisher
ISBN-13 9781785280122
Pages 388 pages
Edition 1st Edition
Languages
Author (1):
John Horton John Horton
Profile icon John Horton

Table of Contents (18) Chapters

Android Game Programming by Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Player 1 UP 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

Coding the game loop


We said that we will not be using a UI layout for our game screen, but instead a dynamically drawn view. This is where the view of our pattern comes in. Let's create a new class to represent our view, then we will put in the fundamental building blocks of our Tappy Defender game.

Building the view

We will leave our two activity classes alone for a while so that we can take a look at our class that will represent the view of our game. As we discussed at the start of this chapter, the view and the controller aspects will be part of the same class.

The Android API provides us with an ideal class for our requirements. The android.view.SurfaceView class not only provides us a view that is designed for drawing pixels, text, lines, and sprites onto, but also enables us to quickly handle player input as well.

As if this wasn't useful enough, we can also spawn a thread by implementing the runnable interface allowing our main game loop to get player input and other system essentials...

lock icon The rest of the chapter is locked
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 $15.99/month. Cancel anytime}