Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Learning LibGDX Game Development- Second Edition
Learning LibGDX Game Development- Second Edition

Learning LibGDX Game Development- Second Edition: Wield the power of the LibGDX framework to create a cross-platform game

Arrow left icon
Profile Icon Suryakumar B Nair Profile Icon Andreas Oehlke
Arrow right icon
€41.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5 (11 Ratings)
Paperback Jan 2015 478 pages 1st Edition
eBook
€32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Suryakumar B Nair Profile Icon Andreas Oehlke
Arrow right icon
€41.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5 (11 Ratings)
Paperback Jan 2015 478 pages 1st Edition
eBook
€32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Learning LibGDX Game Development- Second Edition

Chapter 1. Introduction to LibGDX and Project Setup

This book will take you on an exciting tour to show and teach you about game development using the open source LibGDX framework. Actually, you have chosen just the right time to read about game development as the game industry is in a remarkable state of change. With the advent of increasingly powerful smartphones and tablets as well as the ever-growing application stores for desktop computers and mobile platforms serving millions of users a day, it has never been easier for Independent Game Developers (also known as Indies) to enter the market with virtually no risks and very low budgets.

In this chapter, you will learn about what LibGDX is and the advantages that it provides when developing your own games. You will also get a brief overview of the feature set that LibGDX provides.

Before you can start developing games with LibGDX, you have to install and set up your development environment accordingly. You will be using the freely available and open source software Eclipse as your Integrated Development Environment (IDE) to set up a basic project that uses LibGDX. It will feature a runnable example application for every currently supported target platform. These platforms are as follows:

  • Windows
  • Linux
  • Mac OS X
  • Android (2.2+)
  • iOS
  • HTML5 (using JavaScript and WebGL)

    Note

    The target platforms, namely, Windows, Linux, and Mac OS X will from now on be referred to as desktop and also share a project in our development environment.

You are going to explore what a game needs by looking at it from a technical standpoint, and why it is so important to plan a game project before the development starts.

At the end of this chapter, you will be introduced to the game project that is going to be developed and enhanced throughout this book.

Diving into LibGDX

LibGDX is an open source, cross-platform development framework, which is designed mainly, but not exclusively, to create games using the Java programming language. Besides Java, LibGDX also makes heavy use of the C programming language for performance-critical tasks to incorporate other C-based libraries and to enable cross-platform capabilities. Moreover, the framework abstracts the complex nature of all its supported target platforms by combining them into one common Application Programming Interface (API). One of the highlights of LibGDX is the ability to run and debug your code on the desktop as a native application. This enables you to use very comfortable functions of the Java Virtual Machine (JVM), such as Code Hot Swapping, which in turn lets you immediately see the effect of your changed code at runtime. Therefore, it will significantly reduce your time to iterate through different ideas or even to find and fix nasty bugs more quickly.

Another critical point is to understand that LibGDX is a framework and not a game engine that usually comes with lots of tools, such as a full-blown level editor and a completely predefined workflow. This might sound like a disadvantage at first, but actually it turns out to be an advantage that enables you to freely define your own workflow for each project. For example, LibGDX allows you to go low-level so you could add your own OpenGL calls if that really became necessary at some point. However, most of the time it should be sufficient enough to stay high-level and use the already built-in functionalities of LibGDX to realize your ideas.

Features of LibGDX 1.2.0

Since the release of LibGDX Version 0.1 back in March 2010, a lot of work has been contributed in order to improve this library. The latest stable release of LibGDX is Version 1.2.0 from June 2014, which we are going to use throughout this book.

Here is a list of features taken from the official website (http://libgdx.badlogicgames.com/features.html).

Graphics

The graphic features are as follows:

  • Render through OpenGL ES 2.0 on all platforms
  • Custom OpenGL ES 2.0 bindings for Android 2.0 and higher versions
  • Low-level OpenGL helpers:
    • Vertex arrays and vertex buffer objects
    • Meshes
    • Textures
    • Framebuffer objects (GLES 2.0 only)
    • Shaders, integrating easily with meshes
    • Immediate mode rendering emulation
    • Simple shape rendering
    • Automatic software or hardware mipmap generation
    • ETC1 support (not available in JavaScript backend)
    • Automatic handling of OpenGL ES context loss that restores all textures, shaders, and other OpenGL resources
  • High-level 2D APIs:
    • Custom CPU side bitmap manipulation library
    • Orthographic camera
    • High-performance sprite batching and caching
    • Texture atlases with whitespace stripping support, which are either generated offline or online
    • Bitmap fonts (does not support complex scripts such as Arabic or Chinese), which are either generated offline or loaded from TTF files (unsupported in JavaScript backend)
    • 2D particle system
    • TMX tile map support
    • 2D scene-graph API
    • 2D UI library, based on the scene-graph API, fully skinable
  • High-level 3D APIs:
    • Perspective camera
    • Decal batching for 3D billboards or particle systems
    • Basic loaders for Wavefront OBJ and MD5
    • 3D rendering API with materials and lighting system and support to load FBX models via fbx-conv

Audio

The following are the audio features:

  • Streaming music and sound effect playback for WAV, MP3, and OGG
  • Direct access to audio device for PCM sample playback and recording (unsupported in JavaScript backend)

Input handling

The various input features are as follows:

  • Using abstractions for mouse and touchscreen, keyboard, accelerometer, and compass
  • The gesture detector that detects taps, panning, flinging, and pinch zooming

File I/O and storage

The following are the features for the file I/O and storage:

  • Filesystem abstraction for all platforms
  • Read-only filesystem emulation for JavaScript backend
  • Binary file support for JavaScript backend
  • Preferences for lightweight setting storage

Math and physics

The math and physics features for LibGDX are as follows:

  • Matrix, vector, and quaternion classes. Matrix and vector operations are accelerated via native C code where possible.
  • Bounding shapes and volumes.
  • Frustum class to pick and cull.
  • Catmull-Rom splines.
  • Common interpolators.
  • Concave polygon triangulator.
  • Intersection and overlap testing.
  • JNI wrapper for Box2D physics. It is so awesome that other engines use it as well.
  • JNI wrapper for bullet physics.

Utilities

The different utilities in LibGDX are as follows:

  • Custom collections with primitive support
  • JSON writer and reader with POJO (de-)serialization support
  • XML writer and reader

Tools

The following are the different tools in LibGDX:

  • Particle editor
  • Texture packer
  • Bitmap font generator

Getting in touch with the community

The LibGDX project enjoys a steadily growing and active community. If you ever find yourself stuck with a problem and you just cannot figure out how to solve it, check out the official forum at http://badlogicgames.com/forum/. There is a great chance someone else has already asked your question and has even found a solution with the help of the community. Otherwise, do not hesitate to ask your question on the forums.

There is also an official IRC channel (#libgdx) on Freenode (https://freenode.net/) where you can find some of the users and developers to talk about LibGDX.

If you want to read about the latest news on development of LibGDX, visit the blog of Mario Zechner who is the founder of the LibGDX project, or follow him on Twitter using the following links:

Also, check out the following links for more in-depth information:

Prerequisites to install and configure LibGDX

Before you can start writing any application or game with LibGDX, you need to download and install the library and some additional software.

To target Windows, Linux, Mac OS X, Android, and HTML5, you will need to install the following software:

  • Java Development Kit 7+ (JDK) (v6 will not work!).
  • Eclipse (the Eclipse IDE for Java developers is usually sufficient).
  • Android SDK; you only need the SDK, not the ADT bundle, which includes Eclipse. Install all platforms via the SDK Manager.
  • Android Development Tools for Eclipse, also known as ADT Plugin. Use this updated site (https://dl-ssl.google.com/android/eclipse/).
  • Eclipse Integration Gradle, use this updated site (http://dist.springsource.com/release/TOOLS/gradle).

To additionally target iOS, you will also need:

  • Mac, as iOS Development does not work on Windows/Linux, thanks to Apple
  • The latest Xcode, which you can get from the Mac OS X App Store for free
  • The RoboVM plugin

Java Development Kit

Due to the fact that LibGDX is a framework based on Java, it is necessary to download Java Development Kit (JDK). To install it, follow these steps:

  1. The software is freely available on Oracle's website: http://www.oracle.com/technetwork/java/javase/downloads/index.html. Enter this address and you will see the following page:
    Java Development Kit
  2. Click on the DOWNLOAD button to start downloading the latest JDK.

    Note

    It is important to choose the JDK instead of the JRE package. The reason is that the JDK package contains the Java Runtime Environment (JRE) to run Java applications and everything else that is required to develop them.

    You will have to accept the license agreement and choose the version that is appropriate for your platform. For example, if you are using a 64-bit version of Windows, choose the download labeled as Windows x64. Here, we are using the 32-bit version that is labeled window-i586:

    Java Development Kit
  3. To install the JDK, simply run the downloaded installer file (for example, jdk-8u5-windows-i586.exe) and follow the instructions on the screen:
    Java Development Kit
  4. On the welcome screen of the installer, click on Next to continue:
    Java Development Kit
  5. Then, keep all the features selected to be installed, and click on Next again to continue, as shown in the following screenshot:
    Java Development Kit
  6. Once the installation is complete, click on the Close button to exit the installer.

Eclipse – Integrated Development Environment

The next step is to download and install Eclipse, a freely available and open source Integrated Development Environment (IDE) in order to develop applications in Java. Go to http://www.eclipse.org/downloads/ and choose Eclipse IDE for Java Developers, as shown in the following screenshot, to download for the platform you are using:

Eclipse – Integrated Development Environment

Once the download is finished, extract the archive to C:\eclipse\.

Downloading LibGDX

Go to http://libgdx.badlogicgames.com/releases/ and choose the libgdx-1.2.0.zip file to download LibGDX.

Note

At the time of writing this book, the latest stable version of LibGDX is 1.2.0. It is recommended to use the same version while working with this book.

The following screenshot shows a list of all the available files:

Downloading LibGDX

In the meantime, create a new folder inside the root folder of your C drive with the name libgdx. Once the download is finished, move the archive to C:\libgdx\.

Installing Android SDK

The Android mobile OS is one of LibGDX's supported target platforms. Before you can create Android applications, you have to download and install the Android SDK.

  1. Go to http://developer.android.com/sdk/index.html and click on the Download the stand-alone Android SDK Tools for Windows button, as shown in the following screenshot. In case you are using an OS other than Windows, you will have to scroll down a bit further, click on Download for other platforms and choose the appropriate platform.
    Installing Android SDK
  2. Once the download is finished, run the installer (for example, installer_r22.0.4-windows.exe) and follow the instructions on the screen.
    Installing Android SDK
  3. You will see the following screen when you try to install the Android SDK. This is because the installer cannot find the JDK although you have already installed it.
    Installing Android SDK
  4. You need to set the value of the environment variable JAVA_HOME to the installation path of the JDK. To find the correct path, go to C:\Program Files\Java\. You will see a folder starting with jdk. Take the full name of this folder (here, it is jdk1.8.0_05) and append it to its path, as shown in the following screenshot:
    Installing Android SDK
  5. The complete path will now look like C:\Program Files\Java\jdk1.8.0_05. Now you have to set the environment variable. Click on the Windows Start button and right-click on Computer. Then click on Properties to open the control panel system window, as shown in the following screenshot:
    Installing Android SDK
  6. Click on Advanced system settings on the left-hand side of the window, as shown here:
    Installing Android SDK
  7. The System Properties window will appear. Click on the Environment Variables button:
    Installing Android SDK
  8. The Environment Variables window will appear. Click on the New button (at the top) that corresponds to User variables for <USERNAME> (the username in this case is andreas), as shown here:
    Installing Android SDK
  9. A window with the title New User Variable will appear. Now, fill in the two text fields. Enter JAVA_HOME in the Variable name field and the JDK's path you found earlier in the Variable value field, as shown in the following screenshot:
    Installing Android SDK

    Great! Now your system is prepared for the Android SDK installer. Make sure to exit the Android SDK installer if it is still running to let the change take effect. You will be presented with the next screen after the installer has restarted.

  10. Now, back in the Android SDK setup, click on Next to continue the installation, as shown here:
    Installing Android SDK
  11. The following screenshot will ask you to choose the users for which the Android SDK should be installed. Usually, the suggested Install for anyone using this computer selection is perfectly fine, so just click on Next to continue.
    Installing Android SDK
  12. Now, choose the installation location on your computer. You can safely keep the suggested location and click on Next to continue:
    Installing Android SDK
  13. After this, you will be asked to choose a start menu folder. Again, you can safely keep the suggestion and click on Install to start the installation process:
    Installing Android SDK
  14. After the installation is complete, click on Next to continue:
    Installing Android SDK
  15. Once the installation is finished, you can choose to start the Android SDK Manager. Leave the Start SDK Manager (to download system images, etc.) checkbox enabled and click on Finish to start the manager:
    Installing Android SDK

    The Android SDK Manager enables you to download system images for the specific API levels you want to develop applications for. For up-to-date and detailed information about Android API levels, check out the link http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels.

  16. Now, choose at least Android 2.2 (API 8) and/or any other higher API levels that you might need and click on the Install 7 packages button to automatically download and install all the relevant files, as shown in the following screenshot. The reason why we want to use at least API level 8 is that the earlier versions before Android 2.2 do not support OpenGL ES 2.0, which we will need in later chapters. Using a certain API level also allows you to control the range of devices that you will be able to see and install on your application via the Google Play Store.
    Installing Android SDK
  17. Once the download and installation process is finished, close the Android SDK Manager window.

Running Eclipse and installing plugins

Great! You are almost done setting everything up. The remaining steps involve running Eclipse for the first time and installing important plugins, which are required to develop applications for Android, iOS, and HTML5/GWT with Eclipse.

Open Windows Explorer, and go to the location where you extracted Eclipse (here, C:\eclipse\), and simply run the program by double-clicking on the executable called eclipse.

Eclipse will ask you to select a so-called workspace. This is the folder where all your projects will be saved. We want to use the C:\libgdx\ folder we created a bit earlier:

Running Eclipse and installing plugins

Select the Use this as the default and do not ask again checkbox if you don't want to see this dialog box every time you start Eclipse. To proceed, confirm the dialog box by clicking on the OK button.

The first time Eclipse is started with a new workspace, it will greet you with a welcome screen. Simply click on the small cross (x) of the Welcome tab to close it:

Running Eclipse and installing plugins

You should now see the standard view of Eclipse, which is also called the Java Perspective. On the left-hand side, you can see the Package Explorer section, as shown in the following screenshot. This is where you will see and manage your different projects. This is all you need to know about Eclipse for the moment.

Running Eclipse and installing plugins

If you have never worked with Eclipse before, it might seem quite overwhelming with all these windows, toolbars, huge context menus, and so on. However, be rest assured that all the steps will be discussed in detail as required to make it easy for you to follow.

To install new plugins, go to the menu bar, and click on Help, and then click on Install New Software. This will open the Install window, where you can type the special repository URLs to browse for new plugins. Google provides a list of such URLs at https://developers.google.com/eclipse/docs/getting_started. You have to choose the correct URL that corresponds with your Eclipse installation.

At the time of writing this book, Eclipse 4.3.2 (Kepler) was the most current version available. According to Google's website, the suggested URL for our version is http://dl.google.com/eclipse/plugin/4.3.

Type the URL in the text field that is labeled Work with and press return to let Eclipse request a list of available downloads. Select everything in the list that is shown in Developer Tools to add support for Android applications. Then, select everything in Google Plugin for Eclipse (required) to install the required Eclipse plugin. Lastly, select Google Web Toolkit SDK 2.5.1 in SDKs to add support for HTML5/GWT applications and click on Next to continue:

Running Eclipse and installing plugins

Now, click on Next to start the installation:

Running Eclipse and installing plugins

You will now be prompted to accept the terms of the license agreements by selecting the I accept the terms of the license agreements option. You have to do this before you can click on Finish to continue, as shown in the following screenshot:

Running Eclipse and installing plugins

The download process should only take a couple of minutes, depending on the speed of your network connection. When downloading is finished, Eclipse will show a security warning that you are about to install unsigned content and wants to know whether it should continue or abort. There is always a potential risk of installing malicious software. However, in this case, the download is provided by Google, a well-known company, which is trustworthy enough. Click on the OK button to accept the warning and continue the installation, as shown in the following screenshot:

Running Eclipse and installing plugins

After the installation is finished, a final restart of Eclipse is required. Click on the Yes button to confirm the restart:

Running Eclipse and installing plugins

Now, let's install the Gradle plugin for Eclipse so that we can import the project into Eclipse via Gradle. For this, let's perform the previous steps again. Go to the Install New Software option in the Help menu.

Enter the URL http://dist.springsource.com/release/TOOLS/gradle in the Work with field:

Running Eclipse and installing plugins

Select Gradle IDE under Extensions / Gradle Integration and click on Next. Continue as you did while installing Eclipse plugins to finish the process.

Additionally, in order to enable the iOS development, you need to install the RoboVM plugin in Eclipse. RoboVM for Eclipse integrates the RoboVM AOT (ahead-of-time) compiler with the Eclipse Java IDE. With this plugin, you will be able to develop native iOS apps in Java and launch them on the iOS simulator and iOS devices from within Eclipse.

Note

To execute an application using RoboVM as backend, you need a Mac with Mac OS X 10.9 or higher version with Xcode 5.0 or higher version installed. However, you can construct the project in Windows and later copy it to Mac for execution.

To download and install the latest RoboVM plugin, we will perform the same steps that we did to install Eclipse plugins earlier. Go to the Install New Software option in the Help menu.

Enter the URL http://download.robovm.org/eclipse/ and continue, as shown in the following screenshot:

Running Eclipse and installing plugins

The latest RoboVM release while writing the book was v0.0.13.

Congratulations! You have just finished the installation of everything that you will need to develop and build your own games with LibGDX.

Creating a new application

The next step is to create a new application. Usually, you would have to create several projects in Eclipse: one project for the shared game code, another one for the desktop launcher, and more for the Android, iOS, and HTML5/GWT launchers. Furthermore, the projects would also have to be configured and linked together in a certain way. This is quite a time-consuming task and more or less an error-prone process for inexperienced users.

Luckily, LibGDX provides tools to generate preconfigured projects for a new application that can be directly imported into Eclipse. There are two tools to create a LibGDX project, the latest one is using Gradle, and the old project setup tool written by Aurelien Ribon. First, we will learn about the old setup tool and then about the Gradle setup tool.

Using the old setup tool

The old project setup tool is an executable JAR file called gdx-setup-ui.jar.

Step 1

You can download the old setup tool from https://github.com/libgdx/libgdx-old-setup-ui, as shown here:

Using the old setup tool

Step 2

To run the tool, double-click on the gdx-setup-ui file. When the program starts, click on the big Create button:

Using the old setup tool

Step 3

In the next window, you will see a box labeled CONFIGURATION on the left-hand side. Here, you can configure what the tool will generate.

Enter demo in the Name field, which defines a common project name for your application. Each launcher project will add its own suffix to it, such as -desktop, -android, or -html. A preview of the outcome is shown in the OVERVIEW box on the right-hand side of the window.

The Package field defines the name of your Java package. This needs to be a unique identifier written in lowercase, which is usually derived from a reversed domain name. You do not have to own a domain name nor does it have to really exist, but it helps in choosing nonconflicting namespaces for Java applications. This is especially important on Android, as identical package names for two separate applications would mean that the already installed application is going to be overwritten by the second one while trying to install it. For this demo application, use com.packtpub.libgdx.demo as the package name for now.

The Game class field defines the name of the main class in the shared game code project. Enter MyDemo as the game class name.

The Destination field defines the destination folder where all the projects will be generated. Click on the blue folder button (just next to the field) and set the destination folder to C:\libgdx\.

In another box called LIBRARY SELECTION, the status of required libraries is shown. If there is any item listed in red, it needs to be fixed before any project can be generated. You will see LibGDX being listed in red in the Required section. Click on the blue folder icon next to it:

Using the old setup tool

Step 4

Then, choose the downloaded archive file libgdx-1.2.0.zip from C:\libgdx\ and click on Open, as shown in the following screenshot:

Using the old setup tool

Step 5

The text color of the LibGDX label should have changed from red to green by now. Click on the Open the generation screen button to continue:

Using the old setup tool

Step 6

Next, click on the Launch! button to generate all the projects, as shown here:

Using the old setup tool

Step 7

All done! You can now go to Eclipse and start importing the generated projects into your workspace. To do this, simply navigate to the Import option in the File menu.

Step 8

In the Import dialog box, open the General category, select Existing Projects into Workspace, and click on the Next button, as shown here:

Using the old setup tool

Step 9

Click on the radio button Select root directory and enter C:\libgdx in the text field. This is the directory where all your generated projects were created. You need to confirm your text input by pressing the return key once. Eclipse will start to scan the directory for your projects and list them. Leave all checkboxes selected and click on the Finish button, as shown in the following screenshot:

Using the old setup tool

Step 10

Eclipse will automatically try to build (compile) all the four newly imported projects in your workspace and probably fail. There are two issues that need to be resolved manually after the import. The first one is reported directly to the Console window in Eclipse. It complains about being unable to resolve the target android-15, as shown in the following screenshot:

Using the old setup tool

You have to open the project properties of the demo-android project. First, select it in the Package Explorer box on the left-hand side. Then, go to the menu bar and navigate to Properties option in the Project menu:

Using the old setup tool

Step 11

The title of the window will say Properties for demo-android. If this is not the case, close the window and make sure you have selected the correct project and try again. Next, select Android from the list on the left-hand side. You will see a list of targets that are available on your system. Select Android 2.2, which uses API level 8, and click on the OK button, as shown here:

Using the old setup tool

Step 12

Eclipse will recognize the change and successfully build the Android project this time.

The second issue requires you to click on the Problems tab in Eclipse. Open the Errors list and right-click on the reported problem, which will say The GWT SDK JAR gwt-servlet.jar is missing in the WEB-INF/lib directory. Choose Quick Fix from the context menu, as shown in the following screenshot:

Using the old setup tool

Step 13

In the Quick Fix dialog box, select Synchronize <WAR>/WEB-INF/lib with SDK libraries as the desired fix and click on the Finish button, as shown here:

Using the old setup tool

The two issues will be solved by now, which means that all the projects are now automatically built without failure and can be compiled.

Note

Though the steps to create a project using gdx-setup-ui might seem difficult, actually it's very easy. In our book, we will generate the project setup for our first game using this setup tool, and later in Chapter 14, Bullet Physics, we will use the Gradle-based tool to generate the project, thereby mastering the two technologies.

Using the Gradle-based setup

For the first game, we will use the projects generated using the old setup tool; however, read this section and understand how it works, so that we can use it later in Chapter 14, Bullet Physics.

You can download the gdx-setup.jar file from http://libgdx.badlogicgames.com/download.html and then click on Download Setup App, as shown in the following screenshot:

Using the Gradle-based setup

However, we have already downloaded the libgdx-1.2.0.zip file, which contains gdx-setup.jar; hence, we will extract gdx-setup from the archive. To run the tool, double-click on gdx-setup to get the following screenshot:

Using the Gradle-based setup

The Name, Package, Game Class, and Destination fields are the same that we learned for the old project setup tool.

The Android SDK field defines the path to where you have installed your android sdk. Click on the Browse button and set it to the android sdk folder. Here, it's C:\Program Files\Android\android-sdk.

We will now select Release 1.2.0 from the drop-down list in the Libgdx Version field. Next under the Sub Projects tab, you can select the hardware platforms that you want to support. Here, we select all four, namely, Desktop, Android, Ios, and Html.

Finally, you can select the extensions (for example, box2d, physics bullet, and so on) to be included in your app. Some might not work on all the platforms for which you'll get a warning. For the demo, we don't need any extensions, hence ignore this part.

Note

Once chosen and created, you will have to add new hardware platforms or extensions manually. For manually adding dependencies, visit https://github.com/libgdx/libgdx/wiki/Dependency-management-with-Gradle.

Now, click on the Advanced button, enable Eclipse, and then click on Save, as shown in the following screenshot:

Using the Gradle-based setup

Now that we have set everything, click on Generate.

Note

The gdx-setup option will prompt you to download and install the latest SDK platform and build tools. Just ignore this. While writing the book, the SDK platform was 19 and build tools were 19.0.3.

It will take a while to download and generate the projects. Make sure that you are connected to the Internet. Finally, it will display BUILD SUCCESSFUL like this:

Using the Gradle-based setup

This means you are now ready to import the project into your IDE, run, debug, and package it! All done! You can now go to Eclipse and start importing the generated projects into your workspace.

You can import projects to Eclipse as in the old project setup by following Step 7 to Step 9. However, in order to access the features of the Gradle plugin, you need to import it quite differently. Navigate to the Import option in the File menu. In the Import dialog box, select the Gradle Project subfolder from the Gradle folder, as shown in the following screenshot:

Using the Gradle-based setup

Now in the Import Gradle Project window, click on Browse and select the folder where you created the demo project. Here, it's C:\libgdx. Then, click on the Build Model button:

Using the Gradle-based setup

It will take a while to build the project. After this, select the different projects and click on Finish, as shown in the following screenshot:

Using the Gradle-based setup

All done! After importing, change the API level of Android to 8 by following Step 10 and Step 11 from the old project setup.

gdx-setup versus gdx-setup-ui

Before entering into the game, let's make a quite distinction between the two project setup tools. Why choose one over the other?

There is no doubt that the Gradle-based setup tool is the best. One of the biggest advantages of using Gradle is the dependency management system. The dependency management system is quick, simple, efficient, and easy. If you are developing a simple project without any extensions such as Box2d, you might use the old setup tool; however, if you are developing a multi-platform project, which might be updated soon, then you can use the Gradle-based setup tool.

The projects generated using Gradle and the old setup tool have some minor naming differences that are illustrated in the following figure:

gdx-setup versus gdx-setup-ui

The Java classes shown in the preceding figure are starter classes; we will learn about them in the next chapter. Although the names for projects, packages, and classes generated by the two tools are slightly different, other aspects of the projects such as the assets folder, manifest files, and project wiring are the same.

Note

All the chapters in this book will be explained based on the projects generated from the old setup tool. However, understanding projects generated from Gradle is very easy because the names are easily comparable.

The old setup tool (gdx-setup-ui) is now not encouraged by LibGDX and it might be phased out later; however, it is included in this book because it will be useful for smaller projects.

You can also see that the projects generated and organized under the C:\libgdx path are different for both tools. The old setup tool (gdx-setup-ui) creates all the five projects in the respective folders, as shown in the following screenshot:

gdx-setup versus gdx-setup-ui

However, the Gradle-based tool (gdx-setup) creates a lot file, as shown here:

gdx-setup versus gdx-setup-ui

Observe that our projects are named core, android, desktop, html, and ios. Additionally, take a note of the build.gradle file. This file is important because this is the file you need to edit in order to add more dependencies (such as hardware platform) or new extensions (such as Box2D or Bullet).

Kicking your game to life

Let's take a moment to discuss what a game basically consists of. From a very high-level point of view, a game can be split up into two parts: game assets and game logic.

Game assets include everything that is going to be used as a kind of working material in your game, such as images, sound effects, background music, and level data.

Game logic is responsible for keeping track of the current game state and to only allow a defined set of state transitions. These states will change a lot over time due to the events triggered either by the player or by the game logic itself. For example, when a player presses a button, picks up an item, or an enemy hits the player, the game logic will decide the appropriate action to be taken. All this is better known as gameplay. It constrains the ways of action in which a player can interact with the game world, and also how the game world would react to the player's actions.

To give you a better idea of this, take a look at the following diagram:

Kicking your game to life

The very first step is to initialize the game, that is, loading assets into memory, creating the initial state of the game world, and registering with a couple of subsystems, such as input handlers for keyboard, mouse and touch input, audio for playback and recording, sensors, and network communication.

When everything is up and running, the game logic is ready to take over and will loop for the rest of the time until the game ends and will then be terminated. This kind of looping is also referred to as the game loop. Inside the game loop, the game logic accumulates all (new) data it is interested in and updates the game-world model accordingly.

It is very important to consider the speed at which updates will occur in the game world. Currently, the game will just run at the maximum speed of the available hardware. In most cases, this is not a desirable effect because it makes your game dependent on the processing power and the complexity of the scene to be rendered, which will vary from computer to computer. This implies that your game world will also progress at different speeds on different computers with an almost always negative impact on the gameplay.

The key to tackle this issue is to use delta times in order to calculate the fractional progress of the game world. The delta time is the real time between the last rendered frame and current frame. Now, every update to the game world will occur in relation to real time that is passed since the last frame was rendered. You will see how this actually works with LibGDX in the later examples.

What you have just read was an overview of the basic concept to create games. Yes, it is that simple! Frankly speaking, there is a lot more to learn before your application becomes a real game. There are lots of topics and concepts waiting to be discovered in this book. For instance, you will need to understand how to use and manage different images in an efficient manner. Efficiency becomes even more important if you plan to target mobile devices such as Android or iOS smartphones, where the available resources are constantly scarce.

Key to success lies in planning

Great! Now you have your development environment set up and a basic understanding of what a game is and what it might need. It appears to be a good idea to dedicate some additional time to think about your first game project and create a plan for it. In general, planning your game projects is what you should always do in the first place before any actual work is done. For novice game developers, it might be very tempting to skip this planning phase, which admittedly is a lot more fun in the beginning, but this approach is very likely to fall short in the long run. You will need some sort of outline of what you want to achieve. It does not have to be a very long and detailed description.

A simple and brief feature list of your design goals will do just fine for this purpose. The reason behind this is that you will make yourself aware of each single feature that is a part of your game. In addition, this list will also serve you as a great tool to measure and compare your progress in the game during the development phase. Bear in mind that game development is a very dynamic and iterative process. Although, you should try to adhere to your list of design goals for most of the time, there should always be room to adapt to shifting requirements. Just keep in mind that adhering to the list will make sure that you are going to push development in the right direction. Conversely, it will let you focus on the important parts first, while also protecting you from running out of time and taking too many detours, which prevents you from reaching the finish line due to unclear goals.

Game project – Canyon Bunny

To make this guide both easy and fun to read, it makes perfect sense to show you how to plan and develop a whole game project throughout this book. As we now know, planning should be the first step to take on the journey of any new game project.

So, let's begin with the outline:

  • The name or working title for the game will be Canyon Bunny
  • The genre will be 2D side-scrolling jump and run
  • The list of actors are as follows:
    • The player character (can jump and move forward and will be controlled by the player)
    • Rocks will be serving as platforms for the player character and items
    • Canyons in the background (for level decoration)
    • Clouds in the sky (for level decoration)
    • Water at the bottom of the level (which will be deadly for the player character)
    • Collectible items (such as gold coins and feather power-up) for the player

Next, it is always helpful to write down some supporting text to further describe the overall behavior of the game, and how the features should be implemented.

Description of the game

The game world is presented in a 2D-side view to the player. The view will scroll horizontally to the right-hand side when the player character moves forward. The background shows distant canyons and clouds in the sky. The bottom of the level is filled with water and will instantly kill the player character if both get in touch with each other.

The player character will move on and jump over to random rocks, sticking out of the water. The width and height will be different to make the game more challenging. The player is only in control of a jump button, which will keep the automatically forward-moving player character from falling down into the deadly water.

The level will be randomly populated with collectible items consisting of gold coins and feather power-ups. Collecting the gold coins will increase the player's high score. The feather power-up grants the player character the ability to fly for a limited time and can be used by repeatedly pressing the jump button. The player's goal is to beat the last high score.

As a picture is worth a thousand words, creating a sketch based on our outline can help us even more to get a better idea of the resulting game. Moreover, changing a sketch is usually a lot easier than having to change (complex) game code. So, you really want to keep it very simple; just grab your pen and paper and start to draw. If you feel lucky or have some time to spend, you can do something more elaborate, of course.

Here is a mock-up for Canyon Bunny:

Description of the game

The previous mock-up has been created entirely by using vector graphics. Using vector graphics in favor of raster graphics for your sketches can be an advantage as they are infinitely scalable to any size without losing the image quality. However, the final graphics used in games are almost, always, rasterized graphics, simply because vector graphics are costly to render in real time. So, the common approach is to create vector graphics and later on export them choosing an appropriate rasterized graphics file format, such as Portable Network Graphics (PNG) for lossless compression with alpha channel support, or Joint Photographic Experts Group (JPEG) for lossy but high compression without alpha channel support.

For more details, check out the following Wikipedia articles:

There is a free and open source tool called Inkscape similar to Adobe Illustrator. It allows you to easily create your own drawings as vector graphics and is available for Windows, Linux, and Mac OS X. Check out the project's website http://inkscape.org/.

Summary

We learned a lot about LibGDX in this chapter and all the other bits and bobs to prepare your system for multi-platform game development, specifically on the following points:

  • We discussed every step in great detail to successfully download, install, and configure all the required software components: JDK, Eclipse, LibGDX, Android SDK, and additional Eclipse plugins for Android, HTML5/GWT, and RoboVM.
  • We learned how to use the project setup tool that comes with LibGDX to easily generate all the required Eclipse projects for a new application and how to import them. We also learned what a game needs to come alive.
  • We found out why planning game projects is so important.
  • We also saw how to plan a game project by writing an outline.

In Chapter 2, Cross-platform Development – Build Once, Deploy Anywhere, we will learn more about how to deploy and run a LibGDX application on all supported target platforms. Building on this knowledge, we will finally jump to the first code examples where the magic happens and take a closer look at it to find out how it works.

Left arrow icon Right arrow icon
Download code icon Download Code

Description

This book is aimed at indie and existing game developers as well as those who want to get started with game development using LibGDX. Basic knowledge of Java programming and game development is required.

Who is this book for?

This book is aimed at indie and existing game developers as well as those who want to get started with game development using LibGDX. Basic knowledge of Java programming and game development is required.

What you will learn

  • Set up a crossplatform project using Gradle and test the base code required for game building
  • Speed up your overall productivity with the stunning JVM Code Hot Swapping feature
  • Use Scene2D to create and organize complex menu structures
  • Automate the creation of texture atlases using TexturePacker
  • Manage and play audio files and add special effects to your game to improve its look and feel
  • Learn 2D physics simulation using Box2D
  • Understand more about 3D programming using the new LibGDX 3D API
  • Use the LibGDX Bullet wrapper for 3D physics simulation
Estimated delivery fee Deliver to Slovenia

Premium delivery 7 - 10 business days

€25.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 28, 2015
Length: 478 pages
Edition : 1st
Language : English
ISBN-13 : 9781783554775
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Estimated delivery fee Deliver to Slovenia

Premium delivery 7 - 10 business days

€25.95
(Includes tracking information)

Product Details

Publication date : Jan 28, 2015
Length: 478 pages
Edition : 1st
Language : English
ISBN-13 : 9781783554775
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 120.97
Learning LibGDX Game Development- Second Edition
€41.99
Libgdx Cross-platform Game Development Cookbook
€41.99
LibGDX Game Development By Example
€36.99
Total 120.97 Stars icon

Table of Contents

15 Chapters
1. Introduction to LibGDX and Project Setup Chevron down icon Chevron up icon
2. Cross-platform Development – Build Once, Deploy Anywhere Chevron down icon Chevron up icon
3. Configuring the Game Chevron down icon Chevron up icon
4. Gathering Resources Chevron down icon Chevron up icon
5. Making a Scene Chevron down icon Chevron up icon
6. Adding the Actors Chevron down icon Chevron up icon
7. Menus and Options Chevron down icon Chevron up icon
8. Special Effects Chevron down icon Chevron up icon
9. Screen Transitions Chevron down icon Chevron up icon
10. Managing the Music and Sound Effects Chevron down icon Chevron up icon
11. Advanced Programming Techniques Chevron down icon Chevron up icon
12. Animations Chevron down icon Chevron up icon
13. Basic 3D Programming Chevron down icon Chevron up icon
14. Bullet Physics Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5
(11 Ratings)
5 star 18.2%
4 star 45.5%
3 star 18.2%
2 star 0%
1 star 18.2%
Filter icon Filter
Top Reviews

Filter reviews by




L. Scott Jun 09, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is gold.. I have to say that this people really explain everything very well. This is my 2nd book about libgdx and my favorite so far. I think I can use all the classes used in this book for my own projects.. The game (Canyon Bunny) is a bit boring but the code is excellent.
Amazon Verified review Amazon
avijit Oct 15, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I will recommend to every game development enthusiastic who has just started developing. Believe me you will be very much benefitted.
Amazon Verified review Amazon
Maxim Apr 23, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
I'm a not advanced game developer, however I'm familiar with Libgdx and basic game development concepts.And I can describe this book as helpful. It honestly covers all declared aspects of the framework.However sometimes it gives too much details and code examples for non libgdx specific things and sometimes it touches the basic concepts and examples only. My personal opinion is I would prefer more details in chapters 11, 13, 14 rather than given details in chapters 5, 6, 9.Anyway, I would recommend this book to everyone who has basic knowledge of Java programming, familiar with game development and interested in libgdx learning.
Amazon Verified review Amazon
Sunghyun Kim Feb 21, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
I am not a game software developer, but got myself interested in it recently,starting with OpenGL ES and later finding LibGDX better choice to start with,because LibGDX has OpenGL ES in it and it works as a game framework.Author starts with very detailed guide on how to set up development environment, followed bybasic architecture and flow of LibGDX and then gives you an illustration ofdeveloping a complete game with Canyon Bunny which I've found easy to understand.In later part, the author touches upon a simple 3D application based on LibGDXwhere the essential stuffs like ray picking and model-based rendering are explained.All the example codes are downloadable from Packt Pub and all worked when I actuallyexecuted them on Eclipse, except for the Android-based Canyon Bunny which crashedon pressing play button, reason for which I am still trying to find.( The reason : java.lang.NoClassDefFoundError: com.badlogic.gdx.physics.box2d.World. If this error ever occurs, copy gdx-box2d.jar from the libs folder of CanyonBunny project to that of CanyonBunny-android project. Then it will work. )In my case, this book worked as a good starting point after which I am moving onto Libgdx Cross-platformGame Development Cookbook.One caveat : As the author says, it lightly touches upon 3D stuffs and if you're more interested in 3D game development,this may not be what you're trying to find.
Amazon Verified review Amazon
Amazon Customer Jun 22, 2016
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Good!
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela