JSON Configurations – Unveiling the Secrets of Secure Game Initialization


Ah, the art of configuration. A ballet danced on a stage of binary, with JSON as the choreographer. Join me today, my dear students, as we delve into the depths of using JSON as a configuration file in GameMaker Studio 2. We’ll navigate through creating, bundling, and loading these crucial files during game startup. And the finale? We’ll unlock the art of encryption and decryption to safeguard our precious game data from prying eyes. Think of it as learning the most intricate steps of a delicate operation plan.

  1. Crafting the Configuration: Imagine a conductor poised before an orchestra. The score in his hands determines how the symphony will be played. That score, dear students, is akin to our JSON configuration file. It defines key settings for our game, making them easy to alter without rummaging through countless lines of code.
global.config = {
    "volume": 80,
    "difficulty": "medium",
    "display": "fullscreen"

var jsonString = json_encode(global.config);
buffer_save("config.json", jsonString);
  1. Bundling the Configuration: We’ve crafted our configuration file. It’s now time to bundle it, ensuring it’s included within the game’s package. Within GameMaker Studio 2, we achieve this by adding our config.json file to the Included Files section of the resource tree. Much like a precious instrument being carefully packed before a concert.
  2. Loading the Configuration at Startup: A game’s startup is like the overture to an opera – it sets the stage for what’s to come. At this point, we load our JSON configuration file, applying the settings as needed. We’ll use the buffer_load function to read our file and json_decode to transform it back into a format GameMaker can manipulate.
var jsonString = buffer_load("config.json");
global.config = json_decode(jsonString);

//Now use these settings in your game
audio_master_gain = global.config[? "volume"];
  1. Encrypting and Decrypting the Configuration: Our configuration file, like a top-secret dossier, contains valuable information. It’s our duty to protect it from the prying eyes of potential hackers. GameMaker offers us a myriad of encryption algorithms to choose from. Here, we’ll use the simple yet effective XOR cipher for illustration.
var jsonString = json_encode(global.config);
var encryptedString = buffer_save("config.json", xor_cypher(jsonString, "secretKey"));

var encryptedString = buffer_load("config.json");
var jsonString = xor_cypher(encryptedString, "secretKey");
global.config = json_decode(jsonString);

To add an extra layer of security, consider obfuscating the name of your configuration file, disguising it amongst other files, just as a secret agent might blend into a crowd.

In conclusion, using JSON as a configuration file is like conducting a symphony. It requires attention to detail, an understanding of the mechanics at play, and the wisdom to safeguard the valuable data within. Armed with this knowledge, go forth, my talented students, and let your games sing with the symphony of well-configured harmony.

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

GIPHY App Key not set. Please check settings


5 Cardinal Sins of JSON Misuse in Game Development – Lessons from a Master


A Symphony of Simplicity: A Journey Through ‘Cats Organized Neatly’