Book Image

Learning LibGDX Game Development- Second Edition

Book Image

Learning LibGDX Game Development- Second Edition

Overview of this book

Table of Contents (21 chapters)
Learning LibGDX Game Development Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Assembling the game world


We will now remove some of the old code that was used to draw test sprites. Additionally, we will add three new constants to define the amount of player lives and the viewport dimension of the GUI camera.

Change the code of the Constants class as follows:

public class Constants {
  // Visible game world is 5 meters wide
  public static final float VIEWPORT_WIDTH = 5.0f;
  // Visible game world is 5 meters tall
  public static final float VIEWPORT_HEIGHT = 5.0f;
  // GUI Width
  public static final float VIEWPORT_GUI_WIDTH = 800.0f;
  // GUI Height
  public static final float VIEWPORT_GUI_HEIGHT = 480.0f;
  // Location of description file for texture atlas
  public static final String TEXTURE_ATLAS_OBJECTS =
     "images/canyonbunny.pack";
  // Location of image file for level 01
  public static final String LEVEL_01 = "levels/level-01.png";
  // Amount of extra lives at level start
  public static final int LIVES_START = 3;
}

Now, remove these two lines of code in...