Game Development Reference
In-Depth Information
As a last addition, we will add a Graphical User Interface ( GUI ) to the scene that
overlays the game world. Sometimes, this is also called a Head-Up Display ( HUD ),
but we will use the term GUI here. The GUI will show the player's score, the number
of extra lives left, and an FPS counter to measure the performance of the game.
To sum up, in this chapter, we will:
• Create game objects such as rocks, mountains, clouds, and so on
• Implement the level loader
• Implement the game GUI
Creating game objects
Before we start implementing each individual game object, we will create an abstract
class called AbstractGameObject . It will hold all the common attributes and
functionalities that each of our game objects will inherit from.
You might want to check the Canyon Bunny class diagram in
Chapter 3 , Configuring the Game , again to get an overview of the
class hierarchy of the game objects.
Create a new file for the AbstractGameObject class and add the following code:
package com.packtpub.libgdx.canyonbunny.game.objects;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
public abstract class AbstractGameObject {
public Vector2 position;
public Vector2 dimension;
public Vector2 origin;
public Vector2 scale;
public float rotation;
public AbstractGameObject () {
position = new Vector2();
dimension = new Vector2(1, 1);
origin = new Vector2();
scale = new Vector2(1, 1);
rotation = 0;
 
Search WWH ::




Custom Search