Book Image

LibGDX Game Development By Example

By : James Cook
Book Image

LibGDX Game Development By Example

By: James Cook

Overview of this book

Table of Contents (18 chapters)
LibGDX Game Development By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Game reuse


Right before we dive into looking at tile maps and creating a wonderful world in which Pete will live, we need to set up our project.

Once you have created the project using the LibGDX setup tool—you should be good at that by now—we will need to create a GameScreen class as before, extending the ScreenAdapter class.

Remember, we will need the following objects in our GameScreen class:

  • ShapeRenderer

  • Viewport

  • Camera

  • SpriteBatch

As this is a platformer, we are going to want a view that is more landscape than we have had before. So, we will have a world size of 640 x 480:

private static final float WORLD_WIDTH = 640;
private static final float WORLD_HEIGHT = 480;

Then, we will keep the core functionality for updating and rendering. So, hopefully, your GameScreen class looks like the following:

public class GameScreen extends ScreenAdapter {
  private static final float WORLD_WIDTH = 640;
  private static final float WORLD_HEIGHT = 480;
  private ShapeRenderer shapeRenderer;
  private...