Wiki

Clone wiki

Frankenstein / JSON format description

Parts library file

Parts library contain following list of properties:

nametypedescription
partFilesString[]List of paths of json files containing individual parts descriptions
bloodImagesString[]List of paths to images containing drops of blood. These are used when creating a 'dead' monster sprite
shadowImagesString[]Paths to images containing shadows
defaultColorsMap<Integer, String>List of base colors used in images in this library. Contains map from color id to color string representation. TBD. If you later need to recolor a monster, you can provide a color mapping to monster generator, and it will replace colors, specified here, with new ones from user-provided mapping with same ids

Example

{
    "partFiles" : [
            "resources/test_set/bodies.json"
            , "resources/test_set/limbs.json"
            , "resources/test_set/eyes.json"
            , "resources/test_set/mouths.json"
    ],

    "bloodImages" : [
            "resources/test_set/blood.png"
            , "resources/test_set/blood2.png"
    ],

    "shadowImages" : [
            "resources/test_set/shadow.png"
    ]
}

Parts descriptions

Each monster part file is a JSON array of objects of class ru.game.frankenstein.MonsterPart These objects have following properties:

nametypedescription
typeEnum {MONSTER_BODY, MONSTER_LIMB, MONSTER_DECORATION}Type of this monster part
attachmentPointsAttachmentPoint[]List of points for attaching new parts to this one. See below description of AttachmentPoint class
imageIdStringId or path of an image for this part. This id will be passed to method load(String) of current implementation of ImageFactory class
tagsString[]List of optional tags. If tags are passed for monster generation, only parts that have at least one of those tags will be used for generation
textDescriptionsString[]List of optional text descriptions for this part. Some of them will be combined with descriptions from other parts to create monster text description, if it is requested by user

Important concept in frankenstein is an Attacment Point. These are points where parts of monsters are connected together. AttachmentPoint object specifies, what limbs can be used together, and how they should be drawn relatively to each other.

nametypedescription
xintx-coordinate of attachment point
yinty-coordinate of attachment point
angleintAngle in degrees. Monster limb attached to this point will be rotated this number of degrees around its own point
availableTypesMonsterPartType[]Types of monster parts that can be attached to this points. E.g. only eyes. Or legs.
groupIdStringOptional id of a group this point belongs to. Same monster part is attached to all points that share same group id
flipHorizontalbooleanIf true, monster part image will be flipped horizontally before applying rotation and translation. This can be used to create symmetrical monsters
flipVerticalbooleanSame, but for vertical flip

Example of a monster part file with a single monster part:

[
    {
        "type":"MONSTER_DECORATION",
        "attachmentPoints" : [
            {
                "x": 13,
                "y" : 6,
                "availableTypes" : [
                    "MONSTER_BODY"
                ]
            }
        ],
        "imageId" : "test_set/dec1.png"
    }
]

Updated