jakubg1 / OpenSMCE

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

Implement powerup generators #37

Closed jakubg1 closed 3 years ago

jakubg1 commented 3 years ago

A powerup generator would be a JSON file containing spawnable powerups and corresponding chances and spawn conditions.

Some important changes would be made as a result:

Example:

vanilla_generator.json

{
  "entries":[
    {"type":"powerup","name":"wild","weight":1000},
    {"type":"powerup","name":"fireball","weight":500},
    {"type":"powerup","name":"lightning","weight":500},
    {"type":"powerup","name":"stop","weight":1000},
    {"type":"powerup","name":"slow","weight":1000},
    {"type":"powerup","name":"reverse","weight":1000},
    {"type":"powerup","name":"speedshot","weight":1000},
    {"type":"powerup_generator","generator":"vanilla_generator_colorbomb.json","weight":500}
  ],
  "fallback":[
    {"type":"powerup_generator","generator":"vanilla_gem.json"}
  ]
}

vanilla_generator_colorbomb.json

{
  "entries":[
    {"type":"powerup","name":"colorbomb_1","conditions":[{"type":"color_present","color":1}]},
    {"type":"powerup","name":"colorbomb_2","conditions":[{"type":"color_present","color":2}]},
    {"type":"powerup","name":"colorbomb_3","conditions":[{"type":"color_present","color":3}]},
    {"type":"powerup","name":"colorbomb_4","conditions":[{"type":"color_present","color":4}]},
    {"type":"powerup","name":"colorbomb_5","conditions":[{"type":"color_present","color":5}]},
    {"type":"powerup","name":"colorbomb_6","conditions":[{"type":"color_present","color":6}]},
    {"type":"powerup","name":"colorbomb_7","conditions":[{"type":"color_present","color":7}]}
  ]
}

How would it work:

First, upon generator data usage, all powerups that do not meet the conditions (if specified) should be removed from the list. Then, from the remaining entries, pick one. When no entries are left, use fallback generator if specified. Else, don't spawn anything.

Notes

jakubg1 commented 3 years ago

Implemented in https://github.com/jakubg1/OpenSMCE/commit/dc0fd91f651cf505141e9e7c27a285e7468e1290

To do:

jakubg1 commented 3 years ago

Done: https://github.com/jakubg1/OpenSMCE/commit/4211f130d5a873e73cbd46cd1ef25fa3630377b1