Skip to content

Getting started

Prerequisites

Before you start, make sure you have:

  • Java 21 SDK or higher installed (see installation instruction Introduction to Programming course)
  • IntelliJ IDEA (Community or Ultimate edition).

Downloading the sample projects

Download one of the sample projects from Brightspace or clone your own git repository via repo.hboictlab.nl. These projects are built with IntelliJ. You can open each project directly in IntelliJ.

All the sample projects have been created using Gradle. Gradle is a tool that can be used to build and run applications. IntelliJ has support for Gradle and should automatically detect that you are using a Gradle project.

What is Gradle?

Gradle is a build automation tool for Java (and other languages). It helps you:

  • Compile your code
  • Download dependencies (libraries your project needs, such as LibGDX and the Saxion Game App)
  • Run your application
  • Package your project into a JAR or ZIP, so that you can send it to friends and family for testing

Gradle uses tasks to perform these actions. For example:

  • run → starts the application
  • build → compiles code, runs tests, and packages the app

IntelliJ IDEA can automatically detect Gradle projects and make it easier to run tasks.

Project structure

A typical game project in Gradle/IntelliJ has the following structure:

name-of-your-game/
├─ build.gradle                      # Gradle configuration with all dependencies
├─ settings.gradle                   # Gradle settings (name of the project)
└─ src/main/java/<packagestructure>/ # Your Java source code
└─ src/main/resources/audio/         # Your sound and music files
└─ src/main/resources/fonts/         # Your fonts (TTF/OTF)
└─ src/main/resources/textures/      # Your images (PNG/BMP)
  • Each folder is a standalone Gradle project.
  • The main Gradle task is run, which launches the game window.
  • The sources for you project are in the folder

What about the other files?

You don't have to worry about these files. They are necessary for the project to work, but you shouldn't edit them. To give you an overview of the other files:

  • .idea/ → Stores the project settings for you IntelliJ project.
  • build/ → This is where Gradle will build your application and store the class files and the jar files. .gradle/ → Gradle cache
  • gradle folder / gradlew / gradlew.bat → Gradle wrapper scripts, needed to build your application of various systems.

Opening the project in IntelliJ

  • Launch IntelliJ IDEA.
  • Select Open.
  • Navigate to one of the example project folders (e.g., examples/1-shapes) and click OK.
  • IntelliJ will detect the Gradle project and ask whether to Import Gradle project — choose Import.
  • Wait for IntelliJ to download dependencies.

Running the Game

You have three options to run each example project.

  1. Open the Gradle Tool Window (View → Tool Windows → Gradle).
  2. Navigate to: Tasks → application → run
  3. Double-click run to start the game.
  4. The previous action has created a run configuration for you in IntelliJ. From now on you can just use that run configuration by pressing the play button.

These steps are visualized in Figure 1.

Gradle explanation

Figure 1. How to run the application for the first time

Option 2: Use the Command Line

  1. Open a terminal and navigate to the project folder:

    cd examples/1-shapes
    
  2. Run:

    ./gradlew run
    

    On Windows, use:

    gradlew.bat run