Skip to content

Getting Started

Anastasia Laczko edited this page May 30, 2021 · 23 revisions

Project Structure

  • assets: Contains supporting assets that aren't directly loaded by the game. This can include wiki images, documentation, texture files, etc.
  • source: Contains the source code of the game following the libGDX project layout.

Running the Game

The game uses the Gradle build tool. Open the source directory with IntelliJ or another IDE with Gradle support to automatically install dependencies. Alternatively, Gradle will install dependencies when you first run the game.

A pre-setup Intellij project is provided which contains tasks to run, test, and build the game. This can be selected from the drop-down in the top right of the editor.

Alternatively from a terminal inside the source directory, you can run:

  • ./gradlew run to run the game.
  • ./gradlew test to run the unit tests.
  • ./gradlew build to build a release version of the game.
  • ./gradlew clean to delete the generated output directory.

Dependending on your OS, you may need to substitute ./gradlew with gradlew.bat or gradle (if globally installed).

Game Introduction

The example game provided is called Box Boy. It is a simple game with a player that runs around a forest filled with ghosts. The following sections will give a light overview on how the game is put together.

Screens and Game Areas

The game is composed of a number of screens and can only display one screen at a time. Within Box Boy there are 3 screens:

The screens are managed by GDXGame, which makes it easy to move between them like a state machine.

When you run the game, you'll first come to the Main Menu Screen. From here you'll see the main menu, where the 'Settings' button will take you to the Settings Screen, and the 'Start' button will take you to the Main Game Screen.

Screen are responsible for initiating important game services, drawing the background and UI, rendering the entities and handling input.

Screens can also contain game areas which makes it easy to create different levels or areas within a screen. An example in the game of this is in the Main Game Screen, which currently has a Forest Game Area.

When using game areas, some of the screen's responsibilities can be delegated to the game areas. In the game, the Main Game Screen intialises important services such as the Physics Service, Input Service, Entity Service, etc., as well as loads assets and creates the UI for the screen. The Forest Game Area is then responsible for loading game area-specific assets, drawing the background tiles, drawing game area-specific UI, creating the trees, player and ghosts, and playing the background music.

Learn more about screens and game areas in Screens.

Entities

There are a number of entities within the game including the trees, player and ghosts.

Learn more about entities in Entity Component System (ECS).

Clone this wiki locally