We are going to start the Flappy Bird game by downloading libGDX framework,
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.
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:
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.
Sub Projects: Select only Android
Extensions: Select only Box2d
We are going to use Kotlin, so check out the line of “Use Kotlin”.
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.
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
Delete this two Java files and create new Kotlin files with the same names in the same folder.
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.
I hope the description was understandable and clear. But, if you have still questions, then leave me comments below! 😉
Have a nice a day! 🙂
Subscribe to receive exclusive content and notifications