Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Methodologies on storing/controlling game data  (Read 288 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 1
    • View Profile
Methodologies on storing/controlling game data
« on: March 12, 2024, 06:58:27 am »
Hello! I am currently using SFML to make a autoshooter (think vampire surivors/magic survival) project and having a lot of fun with it, but am starting to hit roadblocks when it comes to ideating how to handle handling game and asset data.

For example, on level up, I want a UI to appear where the player can select a weapon to gain/level up.
There is an weaponArray with the player's current weapons, but this of course is not inclusive of all weapons if the player does not have it.
I want this ui to include such weapons however, and to have descriptions, icons, and names specific to each weapon. Now I could likely create and access an array or struct, define all the weapons, but there may be in-game progression roadblocks on the weapon's addition (thus not wanting to add it to the eligible weapons on level up) - a lot of things to consider.

  • A bit of research has lead me in the direction of scripting - but I'm not even sure what this is and where to begin with it. Is it something specific to SFML or C++, and is lua the only option or is python also one?
  • I have also heard information on json files being used for metadata - but what is the benefit of json over simple text files?
  • Or am I simply overcomplicating things and should I stick to developing in C++. Are there any other approaches to consider?

I feel like I'll run into the same issues with dialogue - writing all the conversations in my .cpp and .h files doesn't seem like something I should do

Thank you for any considerations. I'm really hoping to be pointed in a general direction/videos to look at to understand my problem and my choices better. I believe these metadata management issues can be solved with straight C++, but should I?
« Last Edit: March 12, 2024, 07:01:10 am by SobStories »


  • SFML Team
  • Hero Member
  • *****
  • Posts: 10936
    • View Profile
    • development blog
    • Email
Re: Methodologies on storing/controlling game data
« Reply #1 on: March 12, 2024, 01:16:35 pm »
There's no right or wrong, especially in gamedev. Some sayings even go as far as "There are well written games and there are released games" ;D

As programmers we're drawn to "solving" problems, thus being able to create nice systems that handle game data in an efficient way, seems like a great solution, but this work needs to be balanced against actually creating the game itself.

My personal take on this is that unless something is hindering you on creating the game, I would just continue with the most straightforward way for you.
This not only prevents you from falling into the "engineering" trap, but it will also help you to solve problems that matter, instead of creating things that you think you need, only to realize later that the underlying problem, was actually something totally different.

The reason Lua and JSON are common options to for scripting or storing data, is that they are "simple" formats, have a wide range of available libraries, lots of people know how to work with it.
I'm sure you can use Python for your scripting as well, if you can find a library to help with that.
For file formats, I recommend to use a well-known format, be it JSON, YAML, TOML, etc. as it makes it easier to work with, e.g. if you want to use another application to read it. There are also great libraries out there to parse it and work with it, so you don't have to write a whole parser.

For storage you can also consider using SQLite, which allows you to not only store data, but also define relations, e.g. what weapons are available for which level upgrade while retaining a complete list of the weapons.

Or in the end you can just create a few more lists with the necessary information. Or dynamically filter the wanted weapons from the primary list into a smaller list to display.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
Dev Blog: https://duerrenberger.dev/blog/