jakubg1 / OpenSMCE

Game engine which allows creating a broad range of marble popper games.
MIT License
14 stars 11 forks source link

Sphere modifiers #43

Open jakubg1 opened 3 years ago

jakubg1 commented 3 years ago

Sphere modifiers would alter newly spawned spheres. Example in level file: -> Replace this:

    "colors": [1,2,3,4],
    "colorStreak": 0.5333333333333333

-> to this:

    "sphere_generation": {
        "colors": [1, 2, 3, 4],
        "color_streak": 0.5333333333333333,
        "modifiers": [
            {
                "modifier": "stone",
                "chance": 0.05
            },
            {
                "modifier": "double",
                "chance": 0.15
            }
        ]
    }

The modifiers field can be omitted if no modifiers are provided. The modifiers would be stored in config/sphere_modifiers/<name>.json files, similarly to powerup generators. Example modifier data: config/sphere_modifiers/stone.json:

{
    "replace_with": [
        {
            "color": -5
        }
    ]
}

config/sphere_modifiers/double.json:

{
    "replace_with": [
        {
            "color": 11,
            "conditions": [
                {
                    "condition": "color",
                    "color": 1
                }
            ]
        },
        {
            "color": 12,
            "conditions": [
                {
                    "condition": "color",
                    "color": 2
                }
            ]
        },
        [...]
    ]
}

Description:

  1. Level files. Each generated sphere has a chance chance to have a given modifier applied. One sphere can get modified multiple times.
  2. Modifier files. The only field in the root object is replace_with. It contains a list of items - each item can have conditions. When an item is chosen, the iteration stops and the effect is applied. Currently the only effect is a color change, but the format may change in the future.