Flappy Bird – Install libGDX

We are going to start the Flappy Bird game by downloading libGDX
which is a free and open-source game-development application framework written in the Java programming language. It is cross-platform, supporting Windows, Android, iOS and web browsers with WebGL support, so it is a good system to learn.

Step 1 – Download libGDX

You can download libGDX using this link.

Download libGDX

Here just click on the download button, and save the set up app on you desktop or somewhere else on you computer.

Step 2 – Install libGDX

The requerement of this tutorial is to have installed Android Studio, so you have to have installed Java as well. It mean you should just be able to open the downloaded file.

If you don’t have Java installed on you computer, then you can download it from here:

Download Java

After you have opened the downloaded libGDX file, then you will get this.

Fill out the fields like you see it on the picture.

Destination: Where you would like to install the files.

Android SDK: If you don’t know it, then just open your Andorid Studio, select from the top menu the Tools option, and here the SDK Manager menuitem. At the top of the window will be the Android SDK Location. Copy this link and paste it into the libGDX.

Sub Projects: Select only Android

Extensions: Select only Box2d

Before you generate the code, click on the Advanced button and this window will pop up for you.

We are going to use Kotlin, so check out the line of “Use Kotlin”.

Step 3 – Open in Android Studio

After a successful generation, we will open the project in Android Studio.

To do this, first open Android Studio. There click File menuoption on the top menu and select Open…  then select the folder of the generated project. If it is done, then OK.

It will take few minutes, be patient. 😉

Step 4 – From Java to Kotlin

Our generated project is in Java, but it supports Kotlin also, because in libGDX we have chosen to use Kotlin. You can check it in the project also, if you open the Project from the left side of the window. From here open the build.gradle of the app.

In build.gradle (Project: App) has to be this lines

    • apply plugin: “kotlin-android”
    • api “org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion”
Create Kotlin classes

To create the necessery Kotlin classes, open again the on the left side of the window the Project tab. Here open the needed folders.

  • android – java – package – AndroidLauncher
  • core – java – package – FlappyBird

Delete this two Java files and create new Kotlin files with the same names in the same folder.

FlappyBird::class


FlappyBird::class

AndroidLauncher::class


AndroidLauncher::class

Step 5 – First run

After the modifications the app still running, check it out and run it on an emulator or on your real device. If everything was successful, then you will see this … strange…. screen in landscape mode. 🙂

Compared to our previous tutorials it looks a little bit different. We have still the create method which runs when the app is run. Now we have a render method as well and it will contain our code because it runs again and again and again. So you can think of it as an ongoing loop and that is where we will put our code to animate our stripes to do our collision detection and everything like that to see where the game actually works.

We have some new classes here as well. SpriteBatches are the most important (arguably the only important) component of 2D drawing. A SpriteBatch contains methods for drawing groups of sprites onto the screen. And we have got textures which are basically images that we work with and think of them as sprites as well.

In the render method we have few lines, which sets the red background color, and draws to the screen the badLogic.jpg image to top the left bottom corner.

Questions

I hope the description was understandable and clear. But if you have still questions, then leave me comments below! 😉

Have a nice a day! 🙂

 


 

Follow and like us:
Click to rate this post!
[Total: 0 Average: 0]

6 thoughts on “Flappy Bird – Install libGDX”

  1. Hi,

    So I have followed this tutorial but when I try and run it for the first time I get the error “Default activity not found”

  2. i’m did all but my screen is not landscape . its just vertical and screen don’t changed when i changed my emulator to Horizontal

Leave a Reply

Your email address will not be published. Required fields are marked *