LibGdx a Cross-platform Game Development Framework

LibGdx a cross-platform game development framework and a best way for beginners who turned into game development. Using LibGdx one can build 2D or 3D games with little efforts only you need to be familiar with the basic programming language. There is a core project that needs to create on java and some little coding needs to make it executable in different platforms like desktop, Android,IOS Html5 etc. We will focus on to develop android games. I am going to start with the very basics step that needs to be setup before the coding part. And then we build some Demo Projects and try to get understand that how the whole code is working.  To work on LibGdx you need to install Java JDK, Android SDK and Ecllipse. There is a TroubleFire section in the blog where you will find solutions of the troubles that might come during your work.

Download the Java Development Kit(JDK) from the below link :-
http://www.oracle.com/technetwork/java/javase/downloads/index.html.

Download the Java Standard Edition JDK for windows platform after downloading execute the downloaded installer file (for example, jdk-7u11-windows-x64.exe) and follow the instructions on the screen. Setup the Environment variable path with your jdk path

Start->Right Click on Computers->properties->Advanced System Setting → Environment Variable
look out to system variable click on Path click to edit add your JDK directory path (like C:\Java\jdk1.7.0_11)

Download the Eclipse IDE from the below link :-
http://www.eclipse.org/ downloads/ and choose Eclipse IDE for java developers for windows platform

Download the latest Android SDK from the below link :-
http://developer.android.com/sdk/index.html click on the Download the SDK Tools for Windows button.
Once the download has finished, run the installer (for example, installer_ r22.0.4-windows.exe) and follow the instructions on the screen.

Let’s Start with LibGdx :-

There are two ways to configure your project either using the LibGdx UI Setup or Manually. We will check out with both ways, but first have a look to the UI setup.

Steps to Configure Libgdx using UI Setup

  1. Go to http://code.google.com/p/libgdx/downloads/list and choose the file libgdx-0.9.9.zip to download Libgdx.
  2.  Extract the Zip file and place it anywhere in your drive Say(F:/libgdx-0.9.9), Open the folder and Double Click on the gdx-setup-ui.jar you will get the below screen.
Libgdx using UI Setup

Libgdx using UI Setup

3.Click on Create.
4. You will see the screen divided in four sections configuration,Library Selection, overview and generation write your Project Name “RainDrop”, Package Name “com.raindrop.main”,Game Class “RainDropMain”, choose your destination directory where your project will reside say F:/Project/Raindrop.

RainDropMain

RainDropMain

5. Look at Library selection portion Download the latest stable version.
6. You will see in the generation portion the “Open the generation Screen” button gets highligted that means that your project is now completed the with the configuration setup click on it.

Open the generation Screen

Open the generation Screen

7. Click to launch.
8. Close the UI Setup.
Checkout the Directory F:/Project/Raindrop you will find four folders there:-

UI Setup

UI Setup

We will need to import this project in our IDE to work on it. We will import only two projects Raindrop which is a core project for our Game, and Raindrop-android to make our project to be executable in android device. Before we start to work, have a look on configuring LibGdx Manually.

Steps to Setup LibGdx Manually :-

  1. Start your Eclipse IDE.
  2. Click to File->New->Android Application Project.
  3. Application Name “Rain Drop”, Project Name->”RainDrop-android”,Package Name->”com.raindrop.main”.
Setup LibGdx Manually

Setup LibGdx Manually

4. Click to Next->Next->Finish.
5. Click to File->New->Java Project

Java Project

Java Project

6. Project Name->”RainDrop”.
7. Click to Finish.
8. Right Click on Raindrop (Core Project) Go to new → Click to Source Folder and Name it “libs”.

RainDrop

RainDrop

9. Copy the gdx.jar and gdx-sources.jar from F:/libgdx-0.9.9 and F:/libgdx-0.9.9/sources into the libs folder of your core project.
10. Now Add      this jars as a support library in your project, By Right Click on the RainDrop Project-.> Properties.

Java Build Path

Java Build Path

11. Go to Java Build Path, Click to libraries-> click to Add Jars and In Jar Selection Window open the Raindrop and select gdx.jar and click to ok.

click to Add Jars

click to Add Jars

12. gdx.jar is now looking in the libraries tab, open up the gdx.jar and click to source attachment, click to edit and  browse the gdx-sources.jar that reside in the libs folder of RainDrop project.

RainDrop projects

RainDrop projects

  1. Click to order and export tab and check the gdx.jar.
  2. Now copy the armeabi ,armeabi-v7a and gdx-beckend-android.jar and paste it to the libs folder of  Raindrop-android project, then your directory will look like as shown below
gdx-beckend-android

gdx-beckend-android

15. Right Click on the properties of Raindrop-android project go to java buiild path click on libraries tab click to Add jar.
16. Open up the Raindrop-android in jar selection window and click on gdx-backend-android.jar and click ok.

Raindrop-android

Raindrop-android

17. Click to Add Jar again and select gdx.jar under the RainDrop Project and click ok.
18. Click to Project tab and click to add check RainDrop and click ok.
19. Click to Order and Export and check the Raindrop project.

Now you are complete with your project configuration and it’s time to start exploring the libgdx treaser. The basic idea of implementing a game from a high level point of view is split up the whole game model 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 for the appropriate action to be taken. All this is better known as game play. 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.

Written By: Abhishek Dabral, Software Developer, Mindfire Solutions

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s