Create your own game from scratch

The recommended method is to pre-compile your game to Java bytecode. See the example Java game which does this and which we will talk about below.

If that is too simple for you, there's a more realistic Kotlin example game too.

It's also possible to write your game in Groovy script, which requires no compilation or IDE, just a text editor. But we don't have an example of that yet.

Building example plugin game

git clone https://github.com/electronstudio/ButtonMasherGame.git
cd ButtonMasherGame
./gradlew desktop:run
./gradlew desktop:jfxnative

App will be in desktop/build/jfx/native/ folder. (You can also build Android and iOS apps but this hasn'be been tested recently.)

./gradlew jar

This will compile all the Java sourcecode into bytecode class files, and then zip them up into a file called something like core/build/libs/core-1.0.jar

Then copy that file into the same directory as the game's resource (graphic and sound) files

cp core/build/libs/core-1.0.jar core/assets/mods/ButtonMasherGame/

Finally copy that entire directory as a subdirectory of your RetroWar install

core/assets/mods/ButtonMasherGame YOUR_RETRO_STEAM_INSTALL/mods/

Next time you run RetroWar it should be available under the mod menu. If it doesn't work, turn on debug in RetroWar settings and take a look at retrowar-log.txt file in your home directory.

Make your own plugin game

The easiest way is to modify the ButtonMasherGame game. Rename the main class, rename the package, create more classes, etc. (It is possible use the LibGDX creator to create a new project, but I won't cover that here)

There are lots of comments in the code to explain how it works! If you prefer Kotlin there is also a Kotlin example game which is more in-depth on getting gamepad input.

    jar {  
        manifest {
            attributes(
                    "RetroWar-Version": "0.14",
                    "Factory-Class": "com.mygdx.game.ButtonMasherGameFactory"
            )
        }
    }

This info gets stored in the jar files output by gradle.
If you change the name or package of the factory or the version of RetroWar you are targetting you must change these fields.

API overview

    public MyGame(GameSession session){   
        super(session, 640, 480, font, font, false);
    }