Android Game Programming by Example
eBook - ePub

Android Game Programming by Example

John Horton

Compartir libro
  1. 388 páginas
  2. English
  3. ePUB (apto para móviles)
  4. Disponible en iOS y Android
eBook - ePub

Android Game Programming by Example

John Horton

Detalles del libro
Vista previa del libro
Índice
Citas

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Android Game Programming by Example un PDF/ePUB en línea?
Sí, puedes acceder a Android Game Programming by Example de John Horton en formato PDF o ePUB, así como a otros libros populares de Computer Science y Programming Games. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Año
2015
ISBN
9781785280122
Edición
1

Android Game Programming by Example


Table of Contents

Android Game Programming by Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Player 1 UP
A closer look at the games
Tappy Defender
Tough retro platformer
Asteroids simulator
Setting up your development environment
Installing the JDK
Installing Android Studio
Summary
2. Tappy Defender – First Step
Planning the first game
Backstory
The game mechanics
Rules for the game
The design
Control
Model
View
Design pattern reality check
The game code structure
The Android Activity lifecycle
The Android Studio file structure
Building the home screen
Creating the project
What we did
Building the home screen UI
What we did
Coding the functionality
Creating GameActivity
What we did
Configuring the AndroidManifest.xml file
What we did
Coding the game loop
Building the view
Creating a new class for the view
What we did
Structuring the class code
The game activity
The PlayerShip object
Drawing the scene
Plotting and drawing
Drawing PlayerShip
The Canvas and Paint objects
Controlling the frame rate
Deploying the game
Debugging on an Android device
Summary
3. Tappy Defender – Taking Flight
Controlling the spaceship
Detecting touches
Adding boosters to the spaceship
Detecting the screen resolution
Building the enemies
Designing the enemy
Spawning the enemy
Making the enemy think
The thrill of flight – scrolling the background
Things that go bump – collision detection
Collision detection options
Rectangle intersection
Radius overlapping
The crossing number algorithm
Optimizations
Multiple hitboxes
Neighbor checking
Best options for Tappy Defender
Summary
4. Tappy Defender – Going Home
Displaying a HUD
Implementing the rules
Ending the game
Restarting the game
Adding sound FX
Generating the FX
The SoundPool class
Coding the sound FX
Adding persistence
Iteration
Multiple different enemy graphics
An exercise in balance
Format time
Handle the back button
The finished game
Summary
5. Platformer – Upgrading the Game Engine
The game
The backstory
The game mechanics
Rules for the game
Upgrading the game engine
The platform activity
Locking the layout to landscape
The PlatformView class
The basic structure of PlatformView
The GameObject class
The view through a viewport
Creating the levels
The enhanced update method
The enhanced draw method
Summary
6. Platformer – Bob, Beeps, and Bumps
The SoundManager class
Introducing Bob
Multiphase collision detection
Player input
Animating Bob
Summary
7. Platformer – Guns, Life, Money, and the Enemy
Ready aim fire
Pickups
The drone
The guard
Summary
8. Platformer – Putting It All Together
Bullet collision detection
Adding some fire tiles
Eye candy
The new platform tiles
The new scenery objects
Scrolling parallax backgrounds
Pause menu with moveable viewport
Levels and game rules
Traveling between levels
The level designs
The cave
The city
The forest
The mountains
The HUD
Summary
9. Asteroids at 60 FPS with OpenGL ES 2
Asteroids simulator
The game controls
Rules for the game
Introducing OpenGL ES 2
Why use it and how does it work?
What is neat about Version 2?
How we will use OpenGL ES 2?
Preparing OpenGL ES 2
Locking the layout to landscape
Activity
The view
A class to manage our game
Managing simple shaders
The game's main loop – the renderer
Building an OpenGL-friendly, GameObject super class
The spaceship
Drawing at 60 + FPS
Summary
10. 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
Adding the SoundManager class
Adding the InputController class
Drawing and moving the asteroids
Scores and the HUD
Adding control buttons
Tally icons
Life icons
Declaring, initializing, and drawing the HUD objects
Summary
11. Things That Go Bump – Part II
Planning for collision detection
Colliding with the border
The first phase of border collision detection
Colliding with an asteroid
The crossing number
The first phase and overview of asteroid collision detection
The CollisionPackage class
Adding collision packages to the objects and making them accessible
Adding a collision package to the Bullet class
Adding a collision package to the SpaceShip class
Adding a collision package to the Asteroid class
The CD class outline
Implementing radius overlapping for asteroids and ships
Implementing rectangle intersection for the border
Performing the checks
Helper methods
Destroying a ship
Destroying an asteroid
Testing for collisions in update()
Precise collision detection with the border
Precise collision detection with an asteroid
Finishing touches
Summary
Index

Android Game Programming by Example

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: June 2015
Production reference: 1250615
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-012-2
www.packtpub.com

Credits

Author
John Horton
Reviewers
Håvard Kindem
José Rodriguez-Rivas
Commissioning Editor
Nadeem N. Bagban
Acquisition Editor
Tushar Gupta
Content Development Editor
Siddhesh Salvi
Technical Editor
Prajakta Mhatre
Copy Editor
Charlotte Carneiro
Project Coordinator
Nidhi Joshi
Proofreader
Safis Editing
Indexer
Tejal Soni
Production Coordinator
Melwyn D'sa
Cover Work
Melwyn D'sa
2323__perlego__...

Índice