sym_merged icon indicating copy to clipboard operation
sym_merged copied to clipboard

Add level generator script (Codegen!)

Open copyrat90 opened this issue 3 years ago • 0 comments

a = World number
b = Stage number
c = Zone number
n = image number (single image can contain multiple zones)

Implement stage-codegen.py

  • [x] Generate game_stage_Wa_Sb.cpp
    • [x] Learn to parse *.tmx file, which is basically *.xml file
    • [x] Restructure bg_wa_sb_n.tmx file(s), so that the zone boundaries can be identified with the zone number.
      • [x] Change Tiled layers so that each zone takes each Tiled layers
      • [x] Find the first non-zero cell from the front and back on each zone, to find top-left and bottom-right cell
      • [ ] (Optional) Fix the helper::tilemap::IndexRect ctor, so that it can take top-left and bottom-right cell
      • [x] (Optional) Add object template to Tiled object layer
    • [x] Parse bg_wa_sb_n.tmx file(s) and generate game_stage_Wa_Sb.cpp
      • [x] When there is no certain entity available on zone c, generate constexpr bn::span<ZoneInfo::{EntityInfo}> Zc_{entityInfo}s_ instead of constexpr ZoneInfo::{EntityInfo} Zc_{entityInfo}s_[]
  • [x] Overwrite game_stage_getter.h to currently existing stages

Optional things

  • [x] Rebuild a stage only when it is edited
    • [x] Compare the modified time of generated zone header and the *.tmx file(s) of the zone
      • os.path.getmtime() considered helpful
  • [ ] Verify if the stage is valid
    • [ ] Check if there is at least one entrance on Z0_entranceInfos_ (index 0 of it is where the stage starts)
    • [x] Check if it has only one black hole (stage clear)
    • [ ] Check if every Zc_exitInfos_ is connected to a valid zone number and a valid entrance index of that zone
    • [ ] Check if every size of the zone is same or bigger than (30, 20) cells
    • [ ] Check if unsupported items present (or simply ignore that one?)
    • [ ] Warn unused entrance (exception: Z0_Ent0, where the stage starts)
  • [ ] Optimize codegen by generating each game_stage_Wa_Sb.cpp asynchronously.

copyrat90 avatar Jul 17 '21 06:07 copyrat90