Beginning Android Games - Zechner - Apress (2011).pdf

(45277 KB) Pobierz
488
CHAPTER 9: Super Jumper: A 2D OpenGL ES Game
Get started with game apps development
for the Android platform
Beginning
Android Games
Mario Zechner
813325365.025.png
 
813325365.026.png 813325365.027.png 813325365.001.png 813325365.002.png 813325365.003.png 813325365.004.png 813325365.005.png 813325365.006.png 813325365.007.png 813325365.008.png
 
488
CHAPTER 9: Super Jumper: A 2D OpenGL ES Game
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
813325365.009.png 813325365.010.png 813325365.011.png 813325365.012.png 813325365.013.png 813325365.014.png 813325365.015.png 813325365.016.png
Contents at a Glance
Contents .............................................................................................................. v
About the Author............................................................................................... xii
About the Technical Reviewer ......................................................................... xiii
Acknowledgments ............................................................................................ xiv
Introduction ....................................................................................................... xv
Chapter 1: Android, the New Kid on the Block ................................................ 1
Chapter 2: First Steps with the Android SDK................................................. 25
Chapter 3: Game Development 101 ............................................................... 51
Chapter 4: Android for Game Developers .................................................... 103
Chapter 5: An Android Game Development Framework .............................. 185
Chapter 6: Mr. Nom Invades Android .......................................................... 229
Chapter 7: OpenGL ES: A Gentle Introduction .............................................. 269
Chapter 8: 2D Game Programming Tricks ................................................... 351
Chapter 9: Super Jumper: A 2D OpenGL ES Game ....................................... 429
Chapter 10: OpenGL ES: Going 3D................................................................ 489
Chapter 11: 3D Programming Tricks ........................................................... 525
Chapter 12: Droid Invaders: the Grand Finale ............................................. 577
Chapter 13: Publishing Your Game.............................................................. 625
Chapter 14: What’s Next? ............................................................................ 637
Index ............................................................................................................... 641
iv
813325365.017.png 813325365.018.png 813325365.019.png 813325365.020.png 813325365.021.png
 
Introduction
Hi there, and welcome to the world of Android game development. My name is Mario; I’ll be your
guide for the next fourteen chapters. You came here to learn about game development on
Android, and I hope to be the person who enables you to realize your ideas.
Together we’ll cover quite a range of materials and topics: Android basics, audio and
graphics programming, a little math and physics, and a scary thing called OpenGL ES. Based on
all this knowledge we’ll develop three different games, one even being 3D.
Game programming can be easy if you know what you’re doing. Therefore I’ve tried to
present the material in a way that not only gives you helpful code snippets to reuse, but actually
shows you the big picture of game development. Understanding the underlying principles is the
key to tackling ever more complex game ideas. You’ll not only be able to write games similar to
the ones developed over the course of this book, but you’ll also be equipped with enough
knowledge to go to the Web or the bookstore and take on new areas of game development on
your own.
A Word About the Target Audience
This book is aimed first and foremost at complete beginners in game programming. You don’t
need any prior knowledge on the subject matter; I’ll walk you through all the basics. However, I
need to assume a little knowledge on your end about Java. If you feel rusty on the matter, I’d
suggest refreshing your memory by reading the online edition of Thinking in Java , by Bruce Eckel
(Prentice Hall, 2006), an excellent introductory text on the programming language. Other than
that, there are no other requirements. No prior exposure to Android or Eclipse is necessary!
This book is also aimed at the intermediate-level game programmer that wants to get her
hands dirty with Android. While some of the material may be old news for you, there are still a lot
of tips and hints contained that should make reading this book worthwhile. Android is a strange
beast at times, and this book should be considered your battle guide.
How This Book Is Organized
This book takes an iterative approach in that we’ll slowly but surely work our way from the
absolute basics to the esoteric heights of hardware-accelerated game programming goodness.
Over the course of the chapters, we’ll build up a reusable code base, so I’d suggest going through
the chapters in sequence. More experienced readers can of course skip certain sections they feel
confident with. Just make sure to read through the code listings of sections you skim over a little,
so you will understand how the classes and interfaces are used in subsequent, more advanced
sections.
xv
813325365.022.png
INTRODUCTION
Getting the Source Code
This book is fully self-contained; all the code necessary to run the examples and games is
included. However, copying the listings from the book to Eclipse is error prone, and games do not
consist of code alone, but also have assets that you can’t easily copy out of the book. Also, the
process of copying code from the book's text to Eclipse can introduce errors. Robert (the book’s
technical reviewer) and I took great care to ensure that all the listings in this book are error free,
but the gremlins are always hard at work.
To make this a smooth ride, I created a Google Code project that offers you the following:
The complete source code and assets, licensed under the GPL version 3,
available from the project’s Subversion repository.
A quickstart guide showing you how to import the projects into Eclipse in
textual form, and a video demonstration for the same.
An issue tracker that allows you to report any errors you find, either in the
book itself or in the code accompanying the book. Once you file an issue in
the issue tracker, I can incorporate any fixes in the Subversion repository.
This way you’ll always have an up-to-date, (hopefully) error-free version of
this book’s code from which other readers can benefit as well.
A discussion group that is free for everybody to join and discuss the
contents of the book. I’ll be on there as well of course.
For each chapter that contains code, there’s an equivalent Eclipse project in the Subversion
repository. The projects do not depend on each other, as we’ll iteratively improve some of the
framework classes over the course of the book. Each project therefore stands on its own. The code
for both Chapters 5 and 6 is contained in the ch06-mrnom project.
The Google Code project can be found at http://code.google.com/p/beginning-android-
games .
xvi
813325365.023.png 813325365.024.png
Zgłoś jeśli naruszono regulamin