LibGDX Game Development By Example
eBook - ePub

LibGDX Game Development By Example

  1. 280 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

LibGDX Game Development By Example

Book details
Book preview
Table of contents
Citations

About This Book

Learn how to create your very own game using the libGDX cross-platform framework

About This Book

  • Learn the core features of libGDX to develop your own exciting games
  • Explore game development concepts through example projects
  • Target games for major app stores quickly and easily with libGDX's cross-platform functionality

Who This Book Is For

This book is intended for those who wish to learn the concepts of game development using libGDX. An understanding of Java and other programming languages would definitely be helpful, although it is not a must.

What You Will Learn

  • Create and configure a libGDX project to get started with making games
  • Get to grips with a simple game loop that will drive your games
  • Manage game assets to reduce code duplication and speed up development
  • Pack game assets together into single assets to increase your game's performance
  • Display textures on the screen and manipulate them with play input
  • Play various types of sounds that a game can generate
  • Design and modify a game user interface with libGDX's built-in tools
  • Develop a game that will run across various platforms

In Detail

LibGDX is a cross-platform game development framework in Java that makes game programming easier and fun to do. It currently supports Windows, Linux, Mac OS X, Android, and HTML5.

With a vast feature set on offer, there isn't a game that can't be made using libGDX. It allows you to write your code once and deploy it to multiple platforms without modification. With cross-platform delivery at its heart, a game can be made to target the major markets quickly and cost effectively.

This book starts with a simple game through which the game update cycle is explained, including loading textures onto your screen, moving them around, and responding to input. From there you'll move on to more advanced concepts such as creating a formal game structure with a menu screen, adding a game screen and loading screen, sprite sheets, and animations. You'll explore how to introduce a font to optimize text, and with the help of a game that you'll create, you'll familiarise yourself with the 2D tile map API to create worlds that scroll as the characters move.

In the final sample game of the book, you'll implement a basic version of an Angry Birds clone, which will allow you to use the physic library box2D that libGDX provides access to. An overview of exporting games to different platforms is then provided.

Finally, you will discover how to integrate third-party services into games and take a sneak peak at the Social Media API to get a basic understanding of how it fits into the libGDX ecosystem.

Style and approach

With this book you'll learn game development with libGDX through example game projects. You'll finish the book with a thorough understanding of libGDX game development, along with completed games that you'll have built yourself.

Frequently asked questions

Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access LibGDX Game Development By Example by James Cook in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming Games. We have over one million books available in our catalogue for you to explore.

Information

Year
2015
ISBN
9781785281440
Edition
1

LibGDX Game Development By Example


Table of Contents

LibGDX Game Development 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. Getting to Know LibGDX
Introducing LibGDX
Setting up LibGDX
Creating a project
What is Gradle?
Importing a project
Summary
2. Let's Get These Snakes Out of This Book!
Why Snake?
Game update cycle
Texture rendering
The batch class
The texture class
The dispose() method
Introducing Sammy the snake
Giving the snake a face
Moving Sammy the snake
Controlling Sammy with event polling
Adding the apple
Increasing the length of the snake
Summary
3. Making That Snake Slick
Introducing the ShapeRenderer class
Adding the ShapeRenderer class
Drawing with the ShapeRenderer class
Final thoughts on the ShapeRenderer class
More on collisions
Stopping the doubleback
Colliding with the body
The state of the game
Adding a state
Player feedback
Restart your engines!
High scores
Handling different screen sizes
Introducing the Viewport
Using the Viewport
Summary
4. What the Flap Is the Hype About?
Why Flappy Bird?
The project setup
Setting up the GameScreen class
Creating Flappee Bee
Flappee Bee
Flapping Flappee
Flower power obstacles
Collisions
Scoring
Adding textures and animations
GUI creation with Scene2D
The Stage class
The Actor class
The Start screen and disposal
The dispose() method
Summary
5. Making Your Bird More Flightworthy
Let's load up them assets!
Implementing the AssetManager parameter
Loading the loading screen!
Packing textures
Measuring the impact
The GDX-tools TexturePacker
Using the texture atlas
I need a Hiero!
What is Hiero?
Summary
6. Onto the Next Platform...Game
Why and what is a platformer?
Introducing Pete the platformer
Game reuse
Tile maps – mapping all over the world!
Introducing Tiled
Creating a new map
The LibGDX Tile Map API
Introducing Pete
Adding our character
Making Pete jump!
Adding our artwork
Collision detection
Adding a collectable
Summary
7. Extending the Platform
Increasing the level
Resizing the Map
Allowing Pete to leave the screen
The camera sees it all
Let's make some noise
Sound effects
Music
If Pete jumps in the game, does anyone hear him?
Summary
8. Why Are All the Birds Angry?
The what, why, and how of Angry Birds
Why?
How?
Setting up LibGDX with Box2D
Code reuse
Box2D with LibGDX
Box2D concepts
Shape
Rigid body
Fixture
Constraint
The contact constraint
Joint
The joint limit
The joint motor
World
Solver
Units
Creating a world!
Nutty Birds
Let's get tiling!
The groundwork
Adding objects
Importing the tile map
Importing the object layer
Importing the naughty ones!
Fire at will!
Take Aim! Fire!
Time for an art attack!
Ladies and gentleman – the main event!
Summary
9. Even Angrier Birds!
The how, what, and why of object pools
Object pools with LibGDX
Hey, look at all these acorns!
Pooling the acorns
Freeing the acorns!
Summary
10. Exporting Our Games to the Platforms
Using all the platforms
Looking closer – Android
Launching the emulator from an IDE
Launching the emulator from the command line
Hang on, how does it work?
Release the Kraken!
Looking closer – iOS
Looking closer – HTML
Getting ready to launch
Summary
11. Third-party Services
How to use platform-dependent libraries
The nice way – via Maven
An alternative to Maven – A project/JAR file
Keeping it cross-platform friendly
FriendFace for Android
A potential trap! (Android)
Summary
Index

LibGDX Game Development 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: August 2015
Production reference: 1210815
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-144-0
www.packtpub.com

Credits

Author
James Cook
Reviewers
Pavel Czempin
LĂ©vĂȘque Michel
Sudarshan Shetty
Acquisition Editors
Subho Gupta
James Jones
Content Development Editor
Nikhil Potdukhe
Technical Editor
Abhishek R. Kotian
Copy Editor
Pranjali Chury
Project Coordinator
Mary Alex
Proofreader
Safis Editing
Indexer
Monica Ajmera Mehta
Graphics
Dan Smallman
Jason Monteiro
Production Coordinator
Arvindkumar Gupta
Cover Work
Arvindkumar Gupta

About the Author

James Cook is a Java software developer from London, England. He is currently touring Australia. He has developed software ranging from banking and mobile applications to games. He has worked for large gaming companies, such as Electronic Arts, Playfish, and Plumbee.
During the day, he can be found working on rapid application prototyping for new social casino experiences. However, during the night, he collaborates with his longtime working partner, Dan Smallman, for Super Cookie Games to create games such as Super Bomb Noms, OMG Dancer!, and Betamax—Sherbet Plains.
Super Cookie Games started out as a simple endeavor for James and Dan to learn how to make games and deliver them to Android, iOS, and the Web. Choosing LibGDX as the platform was a key component for the success of this duo, with six different games across three app stores culminating in 50,000 downloads—a testament to LibGDX and its brilliant feature set and ability.

About the Reviewers

Pavel Czempin is currently completing an internship in the software field and plans to study engineering at a German university. Most of his programming experience stems from his early enrollment in a bachelor's course in computer science. In his free time, he likes to program and develop games.
You can find some of his pro...

Table of contents

  1. LibGDX Game Development By Example