Wiki

Clone wiki

Frankenstein / Home

Frankenstein

Frankenstein is a simple Java library for procedural generation of monster images for computer games, using fixed set of pre-drawn parts.

frankenstein

In order to use this library, you need to create monster part images - various body parts, limbs, eyes, mouths etc, and provide their descriptions, defining how they should be combined. Frankenstein will then use these descriptions and generate unique monster images, as well as some additional optional stuff (dead monster images, text descriptions etc)

Usage

Frankenstein can be used both as a library, and as an external application. In order to use it, you first have to create monster parts library. Such library contains a set of monster parts, as well as additional metainformation. Example can be seen in frankenstein-example project. Description of metainfo format can be found here.

Using as library

#!java
// load a parts library from a json description file
MonsterPartsSet partsSet = MonsterPartsLoader.loadFromJSON(new FileInputStream("parts.json"));
// creating generator using this library and default java image manipulation engine
MonsterGenerator generator = new MonsterGenerator(new BufferedImageFactory(), partsSet);
// setting up parameters for generating a simple monster with only one image (not generating additional 'dead' image, text descriptions and other stuff
MonsterGenerationParams params = new MonsterGenerationParams(false, false, null);
// generating monster
Monster m = generator.generateMonster(params);

Monster object contains different fields, that can be generated if corresponding property is set in MonsterGenerationParams. Currently, only monster image itself is created. Dead image, text descriptions and other cool stuff is in progress.

Using as a standalone application

For easiness of use, a sample standalone java application is provided that uses small test set of monster parts. It can be found in frankenstein-examples module.

There are .bat and .sh scripts for running it in a full library zip distribution.

Application main class is ru.game.frankenstein.testapp.FrankensteinTestApp

It has following arguments:

  • -i Path to .json file with monster parts library description. Sample library is included and located in resources/test_set folder.
  • -o Output directory, where generated images will be stored
  • -c Number of images to generate, defaults to 3
  • -s Random generator seed. Running program with same seed values will produce same monsters.
  • -v Print version information

Of course you can use this library not only for generating monsters, but for arbitrary image processing. Here is example of plant sprites generation from my Aurora game project:

frankenstein

Using with 2d game engines

If you are writing a 2d game, you probably use some kind of a game engine, such as Slick 2d, jMonkeyEngine or others. Most probably, such engine has its own format of Image object, so it is good to have Frankenstein work with it directly, instead of converting to and from java standard BufferedImage.

In order to create such bridge between Frankenstein and your game engine, you need to implement 2 interfaces - ru.game.frankenstein.ImageFactory and ru.game.frankenstein.FrankensteinImage.

First one incapsulates all logic for loading image files. Here the most important method is load(String id), as it will be used to load images, specified in your monster part library config.

Second one contains a few image manipulation methods, like drawing one image over another, flipping, rotating etc.

Sample implementation, that uses standard java BufferedImage inside, is already included and located in ru.game.frankenstein.impl.imageio package.

Other stuff

Updated