tristanstraub / thecreeps-godotclj

Clojure implementation of Godot engine tutorial

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Description

An example demonstrating Clojure/JVM bindings against the Godot game engine GDNative API.

It reimplements the tutorial found at https://docs.godotengine.org/en/stable/getting_started/step_by_step/your_first_game.html using GDNative and Clojure.

On the JVM, it provides NREPL. It can be built as a native shared library using GraalVM native-image.

The game is in this repository. The bindings are generated in the godotclj library.

The following projects are linked as git submodules, which will be brought in when make is run:

CAVEAT: The current wrapper around the GDScript API is clunky and can be vastly improved. The main focus has been to ensure that JVM and native builds continue to work side by side, while getting the godot engine tutorial implemented.

Getting started

Clone this repository, and refer below to Building for the JVM and Running

Dependencies

  • openjdk (15.0.1+, but probably java 11, aswell), clojure (1.10.3), godot (3.3.4;64-bit;linux;standard version), g++, clang, gnu make, graalvm (ce-java11-21.2.0, ce-jdk17-21.3.0)

It is expected that godot, g++, clang, and make are to be found on PATH. GraalVM will be found via the GRAALVM_HOME parameter.

OS

Has been seen working on the following operating systems:

  • Fedora 32
  • Ubuntu 20.04

Building for the JVM

The Clojure code needs C wrappers to be generated and built around the GDNative API. Run the following, before starting godot:

git submodule init
git submodule update
make

This brings in “godot-headers” and “godotclj” as submodules, and downloads the assets for the game, and generates GDNative bindings.

Running

The first time the game is loaded by godot, the editor needs to be invoked to import the assets. Run the following script, which expects the “godot” executable to be on the PATH:

./godotclj/scripts/godot.sh --editor --quit

Then, to run the game from the command line, run godot without any arguments:

./godotclj/scripts/godot.sh

This will also start an NREPL session.

Building with GraalVM native image

Run the following, with an appropriate value for GRAALVM_HOME:

make -k RUNTIME=graalvm GRAALVM_HOME=$HOME/vendor/graalvm-ce-java17-21.3.0 all

Running is the same as for the JVM:

./godotclj/scripts/godot.sh

ISSUES

  • the native image is huge, growing from 17MB to over 90MB during development. This issue can probably be resolved. These had compressed sizes of 4MB and 20MB, respectively, which is probably ok.
  • the mapped-instance api is somewhat clunky, and can be improved upon.
  • native-image segfaults on exit
  • some GDNative object memory leaks

About

Clojure implementation of Godot engine tutorial

License:MIT License


Languages

Language:Clojure 87.6%Language:Makefile 12.4%