Getting Started - UQdeco2800/2022-studio-3 GitHub Wiki
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.
From IntelliJ
A pre-setup Intellij project is provided which contains tasks to run and test the game.
-
Create a new directory .idea under source/, so that the path of this folder is game-engine/source/.idea/
-
Copy the contents of .idea.template into .idea. You should now have the path game-engine/source/.idea/workspace.xml
-
Open the source directory in IntelliJ as an existing project. Say yes to importing Gradle settings.
-
Under project settings (File > Project Structure > Project), select version 17 as the project SDK and language level.
The project may ask you to set your Gradle JDK, use the same JDK or JDK17 for this as well.
- Run or edit the game using the provided build tasks.
From command-line
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).
On MacOS
Depending on your version of MacOS, you may encounter an issue with the game launching but no screen appearing. Make sure you check the MacOS Setup Guide to troubleshoot this issue and get the game running.
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:
- Main Menu Screen:
/screens/MainGameScreen.java
- Main Game Screen:
/screens/MainMenuScreen.java
- Settings Screen:
/screens/SettingsScreen.java
The screens are managed by GDX Game: /GdxGame.java
, 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.
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. The Forest Game Area is a good place to get started within the code: /areas/ForestGameArea.java
.
Screen are responsible for initiating important game services, drawing the background and UI, rendering the entities and handling input. 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 Game 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).