25,19 €
Learn how to build an exciting 3D game with LibGDX from scratch
If you are a game developer or enthusiasts who want to build 3D games with LibGDX, then this book is for you. A basic knowledge of LibGDX and Java programming is appreciated.
LibGDX is a hugely popular open source, cross-platform, Java-based game development framework built for the demands of cross-platform game development. This book will teach readers how the LibGDX framework uses its 3D rendering API with the OpenGL wrapper, in combination with Bullet Physics, 3D Particles, and Shaders to develop and deploy a game application to different platforms
You will start off with the basic Intellij environment, workflow and set up a LibGDX project with necessary APIs for 3D development. You will then go through LibGDX's 3D rendering API main features and talk about the camera used for 3D.
Our next step is to put everything together to build a basic 3D game with Shapes, including basic gameplay mechanics and basic UI. Next you will go through modeling, rigging, and animation in Blender. We will then talk about refining mechanics, new input implementations, implementing enemy 3D models, mechanics, and gameplay balancing.
The later part of this title will help you to manage secondary resources like audio, music and add 3D particles in the game to make the game more realistic. You will finally test and deploy the app on a multitude of different platforms, ready to start developing your own titles how you want!
A step by step guide on building a 3D game with LibGDX and implementing an exhaustive list of features that you would wish to incorporate into your 3D game
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 178
Veröffentlichungsjahr: 2016
Copyright © 2016 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 authors, 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 2016
Production reference: 1220816
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78528-841-8
www.packtpub.com
Authors
Sebastián Di Giuseppe
Andreas Krühlmann
Elmar van Rijnswou
Copy Editor
Zainab Bootwala
Reviewer
Jean-Baptiste Simillon
Project Coordinator
Izzat Contractor
Commissioning Editor
Amarabha Banerjee
Proofreader
Safis Editing
Acquisition Editor
Aaron Lazar
Indexer
Tejal Daruwale Soni
Content Development Editor
Anish Sukumaran
Graphics
Abhinash Sahu
TechnicalEditor
Kunal Chaudhari
Production Coordinator
Aparna Bhagat
Sebastian Di Giuseppe started back in 2011 with Java game development and native Android development. With a huge passion, he spent a lot of time learning the different areas of game development, exploring programming areas, and creating prototypes of all kinds for several platforms. With a good plan for his improvement while having a full time job as an Android developer, he also spends a lot of time on the forum, java-gaming.org, learning and making contacts. He joined forces with a graphic designer and a musician to peruse more professional tasks and updates on their work that led him to meet a team of developers who called themselves Deeep Games. With them, he took a step up and also learned project and product management. With time, he joined and consulted other game development teams on management and processes. He now works as a full-time project and product manager and you can see him hang out on the Indie Game Developers' Facebook group posting updates on prototypes, ideas, or recruiting for future projects. You check out his LinkedIn profile at https://ar.linkedin.com/in/sebadigiuseppe or his Facebook profile at https://www.facebook.com/sebastian.digiuseppe.54.
I'd like to thank, Elmar Van Rijnswou and Andreas Krülmann for inviting me to join Deeep Games, which was a huge boost to my career. Packt Publishing, along with Aaron Lazar and Anish Sukumaran take a huge gratitude from me for being so patient, helpful, and supportive on the project, and for giving me this huge opportunity. Also, thanks to Oliver Mendoza for helping synthesize an easy and representative 3D model development along with its other areas.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
Building a 3D Game with LibGDX is a book about how to create games with LibGDX that can work in 3D. We'll cover camera differences with 2D primitive shapes, a game design “on the run” approach, modeling our assets, getting assets from websites, preparing our models and downloading them to be used with LibGDX, animations, textures, a basic UI and with Tweening, all toward developing a basic FPS game. And finally, we will get to export to a desired platform along with troubleshooting usual problems.
Chapter 1, Setting Up Your Development Environment, will cover everything we need to install in order to have a workflow.
Chapter 2, An Extra Dimension, will go over the differences between a 2D and a 3D camera, and then set up a base to work with and draw primitive shapes.
Chapter 3, Working toward a Prototype, will go over the creation of a prototype, from the creation of a level with enemies, chase mechanics, physics, collisions, a user interface, and a mechanism to defend ourselves from the enemies.
Chapter 4, Preparing Visuals, will walk us through the basics of how to use Blender and go step by step through how to create a representative model for our game.
Chapter 5, Starting to Look Like an Actual Game, will help you prepare and import the model created in the previous chapter as well as from other sources. We will also get collision shapes from a static model and add basic shadows.
Chapter 6, Spicing Up the Game, will help you polish your game a little by adding a particle system and some UI Tweening. You will also work a bit on the performance of the game and explore the .NET API, brought by LibGDX, by adding online Leaderboards.
Chapter 7, Final Words, will demonstrate deploying games on various platforms and some basic troubleshooting. This chapter will also help you identify the platform we are running the game on, and finally, talk about room for improvement.
For this book we'll need the following:
If you are a game developer or an enthusiast who wants to build 3D games with LibGDX, then this book is for you. Some basic knowledge of LibGDX and Java programming is required.
Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
You can download the code files by following these steps:
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Building-a-3D-Game-with-LibGDX. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/Buildinga3DGamewithLibGDX_ColorImages.pdf.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at [email protected] with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.
LibGDX's development is very powerful, and that is why we will set up a nice and stable structure to work with before jumping into the code and project structure. We will use IntelliJ IDEA to do most of our development for the simply because it's productive (and of course, there are few neat tricks to combine with LibGDX), though it's very common to use Eclipse for development too. There are other ways to set up a 3D game with LibGDX, but to start off this book; we will build the game with basic assets created by code. In this chapter, we will explain how to download and set up all the required tools to get you started with setting up an environment to build 3D games with LibGDX, and to work on desktop and Android platforms. Although LibGDX also builds for HTML (WebGL) and iOS, we won't cover these builds because they do not fit with our game, but they are as easy as the following documentation guidelines on the official site (http://libgdx.badlogicgames.com/). You will learn more about this in this chapter.
Assuming you know LibGDX, you already have the Java Development Kit (JDK) installed and the Android software development kit (SDK) updated (you need API 22 with the LibGDX version [1.6.4]); otherwise, a simple Google search will do. The steps are OS-free and we will use Windows to implement them.
We will cover the following topics in this chapter:
LibGDX is a Java cross-platform game development framework that released its first version in 2009. It lets you go as low-level as you want to and gives you direct access to all kinds of areas of development. It also comes with an OpenGL ES 2.0 and 3.0 wrapper interface, which is the one that lets us perform 3D development.
3D development with LibGDX already has a nice array of games under its belt already. The following screenshot shows a very popular game called Grandpa's Table, which is available on Android, iOS, and Amazon:
The following is a screenshot of an Android game named Apparatus:
The following screenshot is of the game Ingress, which is available on Android and iOS:
These are just a few of the most popular games out there.
We will not only cover as much as we can from this 3D API—to get the most of it and show a general structure for how to keep things organized and optimal—but also the use of other LibGDX tools to get the most of the framework too.
Download the latest version of IntelliJ IDEA Community Edition for Java developers from https://www.jetbrains.com/idea/download/; it will suggest the download versions compatible with your current operating system. Select the version that best suits your operating system platform, which will either be 32-bit or 64-bit.
At the time of writing this book, IntelliJ IDEA Community Edition (14.1.4) is the latest version.
At the time of writing this book, LibGDX was in version 1.6.4 and we will use that version. Download the setup app from http://libgdx.badlogicgames.com/download.html and open it:
Set up your project name (ours will be called Space Gladiators) and package name (ours is com.deeep.spaceglad). Enter the game's main class name (ours is Core), set the destination path to your preferred directory, and point out the Android SDK directory location.
We will check the Desktop, Android, and iOS project, but leave out Html since we will use the Bullet physics API, which doesn't work on HTML because of the Google Web Toolkit (GWT) backend (for more information, check out http://www.badlogicgames.com/wordpress/?p=2308).
From Extensions, we'll select Bullet (Bullet physics API), Tools (Bitmap Font Generator [Hiero], 3D Particle Editor, and TexturePacker), Controllers (Controller Input API), and Ashley (Entity System API).
LibGDX comes, as you can see, with a lot of very useful tools that you should use for some time and explore them. We'll cover these selected APIs in some depth over the course of this book.
Click on Generate and wait. After it is done, open IntelliJ IDEA and click on Import Project. Go to your newly created project and look for a file called build.gradle, and IntelliJ will do everything else.
Running and debugging the app with IntelliJ IDEA is as simple as a click, but sometimes, we need to perform extra configurations on the IDE to avoid exceptions.
Once IntelliJ is done with all the processes, the default app to run will be Android. To run it, click on the Bug or Play buttons to the right of the navigation bar:
Gradle will build and the Choose Device dialog will pop up, from which you'll choose the Android device on which you'll run the app (either an emulator or a physical device), for which you just have to plug in your device.
To run the desktop app we have to change the default configuration and add the desktop launcher:
Now instead of android at the top, you'll see desktop. You can run or debug with the two buttons to the right of it.
In this chapter, we introduced IntelliJ IDEA and its basic use; we also explained how to download and install it, and set up LibGDX Project for 3D work. We configured our work environment and launched the Android application into an actual device and the desktop application.
In the next chapter, we'll take the plunge to it and learn about LibGDX's 3D rendering API, perspective camera, 3D workflow, and more.
Now that everything is set up, we can move onto the more interesting stuff, (the reason you bought this book), work in three dimensions! This requires new camera techniques: the third dimension adds a new axis instead of having just the x and y grid; a slightly different workflow, and lastly, new render methods are required to draw our game. In this chapter, you'll learn the basics of this workflow to have a sense of what's coming, such as moving, scaling, materials, environment, and some others, and we will move systematically between them, one step at a time.
In this chapter, we will cover the following topics:
The goal of this book is to successfully create a shooter game, as stated earlier. In order to achieve this, we will start with the basics: making a simple first-person camera. We will facilitate the functions and math that LibGDX contains.
