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, ...

Get LibGDX Game Development By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.