- 1 : Overview
- 2 : Environment SetUp
- 3 : Creating Project in libGDX
- 4 : Importing Projects in Eclipse
- 5 : Executing demo project for Windows
- 6 : Executing demo project for Android
- 7 : Executing demo project for HTML5
- 8 : Developing a real flappy bird game remake game using libGDX from scratch
- 9 : Environment Set Up for Game
- 10 : Understand basics of Game
- 11 : Exploring States and Game State Manager
- 12 : Create Play State and Make Bird Fly
- 13 : Building Obstacles and flying through them
- 14 : Collision and sound effect
- 15 : Porting the Game in Android Device
- 16 : libGDX More possibilities to Brisky Demo
- libGDX Example Code : Implementing Google Play Services Leader Boards in LibGDX
- libGDX Example Code : Text and line Animation
- libGDX Example Code : Experimenting Viewports with Text and Shape Animation for multiple screen Resolutions
- Step by Step Tutorial on libGDX
Step 10 : Step by Step libGDX Tutorial : Understand basics of Game
Environment is all set and we are ready to start the Game development . I hope you guys have already played this game downloaded on your android or Desktop and you understand what is this game all about and have noticed what are the various components in the game like :
- Loading Screen
- Menu Screen
- Play screen
- How to Play Screen
- Bird
- Pipes
- Score
- Ground
- Bird changes colour whenever we start a new Game
- Pipes change colour after each score increase
- Bird is killed whenever it touches any Pipe or Ground or Sky
- Game Over State
- High Score
- Medals according to high score
- Play again Button
If you haven't played the game yet , Play it first so you understand all these components as mentioned above . Download links are shared in previous Tutorials but i will mention it once again
Download Android Version @Google Play Store Search using Brisky Bird or VersionPB @ Play Store
Ok lets understand some basic terms about the game like :
Game State
A Game state is the state of a game i.e. for example A Game can be in Menu State , Pause State , Play State , Resume State , Game Over State etc . So in our Game we have :
Splash State : State which we see as soon as the game is started
Menu State : This state comes after Splash State is end and it gives us 2 options
- See How to play Game by tapping on How to Play Game Button
- Tap on any where else on the game except on How to Play Button to Start playing the Game
How to Play Game State : This State basically tells how to play the game in a simple text
Play State : In this state we play the game and do most of the tasks our game does like
- Controlling the Bird
- Bird Jumping whenever we Tap
- See pipes coming and how pipes move towards the bird etc
Game Over State : This state comes whenever the bird is killed .
We will discuss each of the state in more details in next sections for now we must just understand which state is which in the Game .
Game World
Game world is a large world , like in our game Brisky Bird it can have pipes , bird , surroundings and more different components at different point of times depending on the situation of the game But we will show user only a small part of the full game world and we will do that by using Camera
Camera
Camera has a view port i.e. Only a rectangular area i.e. a specific height and width and it shows that only that height and width of our game world to user at any point of the game
Basic Game Lib
It has 2 main parts
- Update Method : It does all the calculations in order for render method to draw pictures on the screen . it includes methods like :
- bird jumping : which calculates gravity i.e. move the bird down when there is no tap and move the bird up when there is a tap , Calculates birds positions etc
- Adjust Pipes positions
- Scoring Logic and so on
- Render Method : Its only purpose is to draw things on the screen . It takes objects on the game world and draws it on the screen
I am sure above points are all clear , lets start doing the basic changes to our code and lets see what changes it makes to our default game code
- Create a new package in our core package named States under com.versionpb.briskybird package
- Inside States create a new abstract java Class called State
- Open the class BriksyDemo and lets create some global variables for width , height and Title for our game as below
In BriksyDemo Class add followinng three lines just below public class BriksyDemo extends ApplicationAdapter {
public static final int WIDTH = 480;
public static final int HEIGHT = 800;
public static final String TITLE = "Briksy Bird Demo";
Lets open DesktopLauncher.java under BriskyBird-desktop package and lets set config to have these global parameters
Enter below 3 lines under LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.width = BriksyDemo.WIDTH ;
config.height = BriksyDemo.HEIGHT;
config.title = BriksyDemo.TITLE;
- Execute Code for Desktop and we will see width , height and title of our default screen is changed .
- Full Code after changes for Desktop Launcher.java and BriskyDemo.java is as below :
DesktopLauncher.java
package com.versionpb.briskybird.desktop;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.versionpb.briskybird.BriksyDemo;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.width = BriksyDemo.WIDTH ;
config.height = BriksyDemo.HEIGHT;
config.title = BriksyDemo.TITLE;
new LwjglApplication(new BriksyDemo(), config);
}
}
BriksyDemo.java
package com.versionpb.briskybird;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class BriksyDemo extends ApplicationAdapter {
public static final int WIDTH = 480;
public static final int HEIGHT = 600;
public static final String TITLE = "Briksy Bird Demo";
SpriteBatch batch;
Texture img;
@Override
public void create () {
batch = new SpriteBatch();
img = new Texture("badlogic.jpg");
}
@Override
public void render () {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(img, 0, 0);
batch.end();
}
}
Table of Contents
- Overview of libGDX
- Environment SetUp
- Creating Project in libGDX
- Importing Projects in Eclipse
- Executing demo project for Windows
- Executing demo project for Android
- Executing demo project for HTML5
- Developing a real flappy bird game remake game using libGDX from scratch
- Environment Set Up for Game
- Understand basics of Game
- Exploring States and Game State Manager
- Create Play State and Make Bird Fly
- Building Obstacles and flying through them
- Collision and sound effect
- Porting the Game in Android Device
- libGDX More possibilities to Brisky Demo