Zombie Bird Tutorial (Flappy Bird Clone/Remake)
Day 2 - Setting up libGDX

Welcome to Day 2. In this section, we will be setting up the libGDX framework, which will do a lot of the low-level work for us, so that we can focus on what matters: gameplay.
Before we move any further, have a look at Zombie Bird to the left, courtesy of Kilobolt's art department. Zombie Bird will be the main character of our game.
As always, the installation/setup is the most boring part of the tutorial. Thankfully, this is very fast and easy! Kudos to the libGDX team for making this easy.
Before we move any further, have a look at Zombie Bird to the left, courtesy of Kilobolt's art department. Zombie Bird will be the main character of our game.
As always, the installation/setup is the most boring part of the tutorial. Thankfully, this is very fast and easy! Kudos to the libGDX team for making this easy.
Setup Java, Download ADT
If you do not have Java installed on your machine, and you do not have Eclipse up and running with Android Development Tools, click here to install those.
Downloading libGDX / Creating Projects
LibGDX offers cross-platform development that lets you write code once and run on multiple platforms. This is possible because in the ligGDX architecture, you have a core Java project in which you write all of your high-level source code (typically using some kind of interface). Whatever code you write in the core Java project will interface with platform-specific code via a variety of platform-specific Java projects (this is the core functionality offered by libGDX).
To set up the core Java projects and the supporting platform-specific projects:
1. Click here to Download the Setup App.
2. Once downloaded, you must do one of the following:
3a. If on a Mac, try double clicking the .jar file.
3b. If on a PC, COPY the downloaded file to the Desktop and then open up a Command Prompt. Type the following:
(DO NOT TYPE THE '>')
> cd desktop
> java -jar gdx-setup.jar
4. Once this has been done, you will see the following screen:
To set up the core Java projects and the supporting platform-specific projects:
1. Click here to Download the Setup App.
2. Once downloaded, you must do one of the following:
3a. If on a Mac, try double clicking the .jar file.
3b. If on a PC, COPY the downloaded file to the Desktop and then open up a Command Prompt. Type the following:
(DO NOT TYPE THE '>')
> cd desktop
> java -jar gdx-setup.jar
4. Once this has been done, you will see the following screen:
6. Enter the information shown below (and in the image above): you may change the Destination to any folder you wish.
Name: ZombieBird
Package: com.kilobolt.zombiebird
Game class: ZBGame
Destination: Your choice. Remember which folder you choose.
Android SDK: The location of your Android SDK installation. If you are using the ADT Bundle (Android Developer Tools: Eclipse + Android SDK, etc.) this is located inside sdk inside the adt-bundle folder.
Make sure that the Sub Projects Desktop, Android, iOS and HTML are checked, and uncheck any Extensions (support classes that offer additional functionality for libGDX).
This will automatically setup five Java projects for us in the destination you provided. The core project will be where we write our game code. The Android, iOS and HTML projects will access the code in our core project and execute it with platform-specific implementation in order to make the game work in each platform.
Name: ZombieBird
Package: com.kilobolt.zombiebird
Game class: ZBGame
Destination: Your choice. Remember which folder you choose.
Android SDK: The location of your Android SDK installation. If you are using the ADT Bundle (Android Developer Tools: Eclipse + Android SDK, etc.) this is located inside sdk inside the adt-bundle folder.
Make sure that the Sub Projects Desktop, Android, iOS and HTML are checked, and uncheck any Extensions (support classes that offer additional functionality for libGDX).
This will automatically setup five Java projects for us in the destination you provided. The core project will be where we write our game code. The Android, iOS and HTML projects will access the code in our core project and execute it with platform-specific implementation in order to make the game work in each platform.

7. Next, we will generate Eclipse projects by pressing Advanced, and selecting "Eclipse"
Note: libGDX uses a build tool called Gradle which automates the task of building your application, manages .JAR dependencies (for adding extensions) and makes it easy collaborate with others. Gradle is a large topic of its own, and you need to have some background in using build tools such as Ant or Maven. Rather than spending a week discussing that topic, we will pretend Gradle does not exist in this tutorial. We plan to post a series of tutorials on this topic at a later time.
8. Once the downloads are finished, simply press the "Generate" button.
9. The setup app will take a minute to complete downloading and configuring your project. Once you see the following message, you may close out of the Project Setup.

10. Now that we have our five projects generated inside the Destination folder from Step 6 (as shown to the left), we can import them into Eclipse. Open up Eclipse.
11. Right click in the Package Explorer and press Import, as shown below.
12. Choose General > Existing Projects into Workspace
13. Click "Browse" next to select root directory:
14. Navigate to the Destination folder from Step 6, and click Open.
15. Select all five projects as shown below, then click "Finish"
16. Now we are done! We have imported our Java projects into Eclipse, and we are ready to start writing code.
Have error messages?
If you have an error in your ANDROID project, right click on it, click Properties, click Android, and make sure that you have a version of Android installed. If this is not installed, you will need to click here and refer to the step called:
II. Installing the Bundle: Eclipse/Android SDK/Eclipse ADT Plugin, before coming back to this lesson.
17. To make sure everything is setup properly, open the ZombieBird - desktop project and navigate to its DesktopLauncher.java class. Update it as shown below:
Have error messages?
If you have an error in your ANDROID project, right click on it, click Properties, click Android, and make sure that you have a version of Android installed. If this is not installed, you will need to click here and refer to the step called:
II. Installing the Bundle: Eclipse/Android SDK/Eclipse ADT Plugin, before coming back to this lesson.
17. To make sure everything is setup properly, open the ZombieBird - desktop project and navigate to its DesktopLauncher.java class. Update it as shown below:
package com.kilobolt.zombiebird.desktop; import com.badlogic.gdx.backends.lwjgl.LwjglApplication; import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; import com.kilobolt.zombiebird.ZBGame; public class DesktopLauncher { public static void main (String[] arg) { LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.title = "Zombie Bird"; config.width = 480; config.height = 320; new LwjglApplication(new ZBGame(), config); } }
18. Right click and Run the DesktopLauncher class (bottom left), and you will see the following (bottom right):
19. If you've gotten this far, libGDX is working properly, and we are ready to move on. Join me in Day 3!
Like us on Facebook to be informed as soon as the next lesson is available.
|
|