Skip to content

Data-Driven Dungeon (JSON Level Loading) - Json#713

Open
222448082Ashen wants to merge 3 commits intothoth-tech:mainfrom
222448082Ashen:usageExamples/json/level-renderer
Open

Data-Driven Dungeon (JSON Level Loading) - Json#713
222448082Ashen wants to merge 3 commits intothoth-tech:mainfrom
222448082Ashen:usageExamples/json/level-renderer

Conversation

@222448082Ashen
Copy link
Copy Markdown

@222448082Ashen 222448082Ashen commented Mar 28, 2026

Description

This PR implements Data-Driven Dungeon (JSON Level Loading). It provides comprehensive usage examples across C++, C#, and Python, while also fixing a critical build failure in the API documentation generation script caused by incomplete metadata.

Type of change

  • Bug fix (fixed TypeError in api-pages-script.cjs due to missing JSON fields)
  • New feature (added two new complex integration examples)
  • Documentation (updated Physics and Json usage indices)

How Has This Been Tested?

  • Local Build: Ran node scripts/api-pages-script.cjs manually to confirm the TypeError is resolved and all MDX files generate successfully.
  • Verification Script: Executed node scripts/usage-examples-testing-script.cjs for both celestial_mechanics-1-example and data_driven_dungeon-1-example to verify the 6-file requirement.
  • C++ Compilation: Verified C++ logic by compiling on Windows using g++ against the SplashKit SDK.

Testing Checklist

  • Tested in latest Chrome
  • Tested in latest Firefox
  • npm run build
  • npm run preview

Checklist

If involving code

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Folders and Files Added/Modified

  • Added:
    • physics (Celestial Mechanics source + metadata)
    • json (Data-Driven Dungeon source + metadata + level_data.json)
  • Modified:
    • api.json (Added full schema for new functions to satisfy build scripts)

Additional Notes

The api-pages-script.cjs was failing because it expects parameters and signatures objects for all functions in api.json. These have been explicitly added for the new examples to restore the Netlify build pipeline.

Add a set of data-driven dungeon usage examples demonstrating JSON-driven level loading and rendering across multiple languages (C#, top-level C#, C++, Python). Includes example source files, a sample level_data.json describing spawn points and loot, a preview PNG, and a short README text. These examples show how to read JSON with SplashKit, draw entities (player, enemies, loot), and perform proper JSON cleanup.
Update scripts/json-files/api.json: enrich the existing data_driven_dungeon entry with parameters, return info, attributes, and language signatures; and add a new celestial_mechanics function entry under the physics group with metadata (parameters, return, attributes, and signatures). These changes expose example metadata for language bindings and documentation generation.
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 28, 2026

Deploy Preview for splashkit ready!

Name Link
🔨 Latest commit 2e47efe
🔍 Latest deploy log https://app.netlify.com/projects/splashkit/deploys/69d0664eaf07d000084175fd
😎 Deploy Preview https://deploy-preview-713--splashkit.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@222448082Ashen 222448082Ashen changed the title Usage examples/json/level renderer Celestial Mechanics (N-Body Gravity) - Mar 28, 2026
@222448082Ashen 222448082Ashen changed the title Celestial Mechanics (N-Body Gravity) - Celestial Mechanics (N-Body Gravity) Mar 28, 2026
@222448082Ashen 222448082Ashen changed the title Celestial Mechanics (N-Body Gravity) Data-Driven Dungeon (JSON Level Loading) - Json Mar 28, 2026
@jankiluitel
Copy link
Copy Markdown

Well done on putting the Data-Driven Dungeon and Celestial Mechanics concepts into practice; this is a powerful and organised contribution.

  • I truly enjoy:The examples are more realistic and scalable due to the usage of data-driven design with JSON.
    Several languages (C++, C#, Python) are included, which is in line with SplashKit's cross-platform objectives.
    Clearly making an attempt to finish the necessary metadata in order to fix the api-pages-script issue

Here are some ideas for enhancements:

  • The PR is difficult to review due to its size (more than 300 lines spread across several sections). Future modifications could benefit from being divided into smaller PRs (e.g., examples vs. build fixes).Since the API was altered.json, it would be beneficial to verify that no current API documentation behaviour is inadvertently impacted.
  • Adding brief comments or explanation in complex sections (especially physics logic and JSON structure) could improve readability for new learners.

Overall, this is a valuable and advanced contribution. Nice work!

Copy link
Copy Markdown

@jankiluitel jankiluitel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a strong and advanced contribution — the data-driven approach using JSON and the inclusion of multiple languages (C++, C#, Python) are very valuable for demonstrating real-world usage.

I especially liked:

  • Clear use of JSON for structured level data (spawn points, loot, metadata)
  • Consistent implementation across multiple languages
  • Inclusion of a visual output (PNG), which improves usability

Some suggestions and potential issues to consider:

  1. Path handling inconsistency (C++):
    The C++ example uses:
    json_from_file("public/usage-examples/json/level_data.json");
    and then falls back to "level_data.json".
    This could cause confusion depending on execution context. It might be better to standardise a single relative path consistent with other examples.

  2. API consistency across languages:
    Python and C# load JSON using simpler paths, while C++ includes fallback logic. Aligning behaviour across languages would improve consistency for learners.

  3. Python refresh function:
    refresh_screen(60) is used, but in SplashKit Python the preferred function is refresh_screen_with_target_fps(). This may cause runtime inconsistencies.

  4. api.json modifications:
    Changes to api.json are quite extensive and tightly coupled to build scripts. It would be good to confirm:

  • No unintended impact on existing API pages
  • All required fields follow the expected schema strictly
  1. PR size:
    This PR combines multiple concerns (new examples + api.json fixes + physics examples). Splitting into smaller PRs would improve reviewability and reduce risk.

Overall, this is a high-quality and complex contribution, but addressing the above points would improve maintainability and consistency across the project.

Add VS Code C/C++ runner settings and tidy usage examples; simplify JSON loading in C++ example (use level_data.json directly), rename local variable to entity_type, and use refresh_screen_with_target_fps in the Python example. Normalize guide group casing in guides-groups.json and extensively update scripts/json-files/usage-example-references.json: add new example entries, adjust many example titles/URLs to use consistent "-functions" anchors (and append carriage returns where present), and add new categories (json, windows, color, geometry, graphics entries). Enhance scripts/usage-example-scraping.cjs to read ./scripts/json-files/api.json and compute canonical example URLs via getApiJsonData and getUsageExampleApiUrl, replacing the prior naive anchor construction. These changes align example metadata and scraper logic with the API index for correct anchor generation and improve local dev editor settings.
@222448082Ashen
Copy link
Copy Markdown
Author

Thank you so much for the thoughtful and detailed review, and for the encouraging feedback. I really appreciate it.

Your points are very fair, and I agree with the direction:

  1. PR scope and reviewability
    I agree this PR became too broad. I will split concerns into smaller PRs so each review is focused and lower risk:
  • Data-Driven Dungeon example
  • Celestial Mechanics example
  • API/build-script related fixes
  1. Path handling consistency
    Great callout. I have aligned JSON loading to one consistent relative path style and removed mixed/fallback path behavior so execution context is clearer.

  2. Cross-language consistency
    I agree this is important for learners. I am aligning C++, C#, and Python behavior so they follow the same flow:

  • load JSON
  • parse rooms/loot/enemies
  • draw/display output
  1. Python refresh API usage
    Also fixed. I updated the Python variant to use refresh_screen_with_target_fps(60) for consistency with SplashKit Python expectations.

  2. api.json and build safety
    I have been validating this carefully to avoid regressions:

  • checked for unintended API-doc behavior changes
  • confirmed generated links/anchors are valid
  • reran the full build pipeline and link validation successfully
  1. Readability improvements
    Agreed. I am adding short comments in dense sections (JSON structure/parsing, spawning, and movement/physics logic) to improve clarity for new learners.

Thanks again for the high-quality review. It helped improve both maintainability and consistency, and I will keep the next updates smaller and more focused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants