Skip to content

JSON data structure containing game configuration settings#769

Open
222448082Ashen wants to merge 2 commits into
thoth-tech:mainfrom
222448082Ashen:usageExamples/json/file
Open

JSON data structure containing game configuration settings#769
222448082Ashen wants to merge 2 commits into
thoth-tech:mainfrom
222448082Ashen:usageExamples/json/file

Conversation

@222448082Ashen
Copy link
Copy Markdown

@222448082Ashen 222448082Ashen commented May 13, 2026

Description

Splashkit Function: json_from_file

Overview of example functionality: This example demonstrates how to create a JSON data structure containing game configuration settings (such as window dimensions, game title, and RGB background color), save the data to a file using json_to_file, and then read it back using json_from_file. The retrieved values are successfully extracted using json_read_string and json_read_number, and then applied to configure and draw a SplashKit window.

Example Output:
(Note: Drag and drop your screenshot json_from_file-1-example.png here when creating the PR on GitHub)

json_from_file-1-example
  • C++ code
  • C# code (Top-Level statements)
  • C# code (Object-Oriented Programming)
  • Python code
  • Relevant title for the example (.txt)
  • Screenshot

Usage Example Checks (READ CAREFULLY)

  • Code uses Splashkit function above
  • Code does not use non-Splashkit functions
  • Code does not use extra function declarations or extra classes
  • Code does not violate any of the Thoth Tech SplashKit Style Guide rules
  • Simple, clear demonstration of the function
  • Tested in Chrome and Firefox

Add a sample game_config.json and multiple usage examples demonstrating reading/writing a game configuration from JSON. Files added: json/game_config.json, examples in C#, C# (OOP), C++, Python, and a short .txt explanation. Each example shows creating a JSON config, saving to file, loading it with json_from_file, extracting gameTitle, windowWidth/Height and backgroundColor, applying those settings to open a window and display values, and cleaning up resources.
Add a new usage example image for the JSON `json_from_file` example at public/usage-examples/json/json_from_file-1-example.png to support documentation and visual reference.
@netlify
Copy link
Copy Markdown

netlify Bot commented May 13, 2026

Deploy Preview for splashkit failed.

Name Link
🔨 Latest commit ba522af
🔍 Latest deploy log https://app.netlify.com/projects/splashkit/deploys/6a0498a61becce0008f9ff31

@222448082Ashen 222448082Ashen changed the title Usage examples/json/file JSON data structure containing game configuration settings May 13, 2026
Copy link
Copy Markdown

@himanshigaba22 himanshigaba22 left a comment

Choose a reason for hiding this comment

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

Nice example - loading game settings from JSON is a really useful idea and easy to follow.

Just a few small things to fix before it can be merged:

The C# top-level file is named json_from_file-1-example.cs, but it should use the -top-level.cs naming
The C# OOP file needs a proper namespace wrapper
The .txt file has multiple lines, but it should just be a short one-line title
The json/game_config.json file might not need to be included since the example creates it itself
Also, open_audio() and close_audio() don’t seem needed here since no audio is used

Can you also confirm if usage-example-references.json has been updated?

Once these are fixed, it should be good to go 👍

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