Skip to content

A 2d game engine in Java. Zero external dependencies other than for transpiling to JS.

License

Notifications You must be signed in to change notification settings

iamdudeman/sola-game-engine

Repository files navigation

sola game engine

sola game engine is a zero external dependency game engine (other than teavm for transpiling to JavaScript) that has been a hobby project for a long time. Two larger pieces of this project were broken into separate repositories for easier maintenance (the entity component system and JSON parser). Its purpose has been primarily for learning about how games are developed from the ground up, but I hope to one day use it to also make some small games.

You can view a collection of demos built with the sola game engine running in your browser at this itch.io page.

Java CI Javadocs Link

Quick Start

You can use the Sola Game Template repo as a template to start your repo using the sola game engine.

The general structure of a Sola project is to first create an instance of Sola. This is where all your amazing game code goes! Then you choose an implementation of SolaPlatform that has all the bindings for your desired platform to actually "play" the Sola.

public class Main {
    public static void main(String[] args) {
        SolaPlatform solaPlatform = new SwingSolaPlatform();
        Sola sola = new ExampleSola();

        solaPlatform.play(sola);
    }
}

Download

Gradle + Jitpack:

repositories {
    maven {
        url = uri("https://jitpack.io")
    }
}

dependencies {
    implementation("com.github.iamdudeman.sola-game-engine:sola-engine:SOLA_ENGINE_VERSION")
    implementation("com.github.iamdudeman.sola-game-engine:platform-swing:SOLA_ENGINE_VERSION")
    implementation("com.github.iamdudeman.sola-game-engine:tooling:SOLA_ENGINE_VERSION")
}

Internally developed libraries uses

Supported Platforms

Example Code

You can execute the example code in the browser at https://iamdudeman.itch.io/sola-game-engine-demos. The local server will have to be downloaded and executed separately.

Games using sola game engine

  1. sola game engine demos
  2. Acid Rain OLC CodeJam 2022
  3. re;memory OLC CodeJam 2023

Packaging for release

Browser zip file

Run the following gradle command

.\gradlew.bat distWebZip

The output will be at examples/browser/build/examples-browser-<version>.zip. This can be deployed to places like itch.io when using the "HTML" project type.

Swing + JavaFx fat jar

Run the following gradle command

.\gradlew.bat distFatJar

The output will be at examples/swing/build/swing-<version>.jar and examples/javafx/build/javafx-<os>-<version>.jar. Your users will need to have Java 17 installed to run the jar.

Swing + JavaFx .exe

You also have the option to use jpackage to create an executable exe file. Your users will not need to have Java installed.

  1. Install JDK 17
  2. Update $JAVA_HOME path environment variable
    • ex. C:\Program Files\Java\jdk-17.0.5
    • To test configuration run: jpackage --version
      • Should see the current jdk version returned: 17.0.5
  3. Run the following gradle command
.\gradlew.bat distFatJarZip
  1. Output will be in the build/jpackage directory

JSON Schema

JSON schema files are provided for various asset types. These can assist you in creating valid assets for the sola game engine to load when manually creating or updating them.

IntelliJ setup

  1. Open settings
  2. Go to Languages & Frameworks | Schemas and DTDs | JSON Schema Mappings
  3. Click + and select the schema file to add
  4. Add by file path pattern (recommendations below)
    • SpriteSheet.schema.json -> *.sprites.json
    • Font.schema.json -> *.font.json
    • GuiDocument.schema.json -> *.gui.json
    • ControlConfig.schema.json -> *.controls.json