Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add level generator script (Codegen!) #3

Open
12 of 20 tasks
Tracked by #2
copyrat90 opened this issue Jul 17, 2021 · 0 comments
Open
12 of 20 tasks
Tracked by #2

Add level generator script (Codegen!) #3

copyrat90 opened this issue Jul 17, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@copyrat90
Copy link
Owner

copyrat90 commented Jul 17, 2021

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

Implement stage-codegen.py

  • Generate game_stage_Wa_Sb.cpp
    • Learn to parse *.tmx file, which is basically *.xml file
    • Restructure bg_wa_sb_n.tmx file(s), so that the zone boundaries can be identified with the zone number.
      • Change Tiled layers so that each zone takes each Tiled layers
      • 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
      • (Optional) Add object template to Tiled object layer
    • Parse bg_wa_sb_n.tmx file(s) and generate game_stage_Wa_Sb.cpp
      • 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_[]
  • Overwrite game_stage_getter.h to currently existing stages

Optional things

  • Rebuild a stage only when it is edited
    • 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)
    • 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 copyrat90 mentioned this issue Jul 17, 2021
16 tasks
@copyrat90 copyrat90 added the enhancement New feature or request label Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant