Advertisement

New member with questions

Started by November 06, 2016 07:24 PM
3 comments, last by Xaegis 8 years, 1 month ago

Hello,

I have some experience with programming in python but not in C++.

I have just encountered the idea of the Component Entity Systems model of design

I was wondering If I could get a little advice on how to start my project and to design it.

I am going to be building an RPG with Network capability (Raknet) using the Leadwerks Game engine using C++.

(I realize I have a lot of ground to cover but I'm not in a hurry and just love the exploration of the languages just as much as the building of the project as it is a long term hobby and nothing more. )

The articles I have consumed so far are here and here.

I am still a little fuzzy on how I should start to assemble my project.

I decided to implement a character generator first to work out the bugs in my programming and to increase my overall knowledge base so that I understand the use of C++, implementing GUI elements (Qt most likely) and basic networking. (client server architecture using the UDP protocols)

My questions are;

  • What is the best practice in C++ for storing the players character data. Do you serialize with json or another method? Does one store it in a binary or .txt file in the program directory?

  • Do I use a database connection to store the players character information?

  • What is the best data structure type to use for this application since the "players" will be mixed data types. (Vector array? List? Struct?)

  • Should the character information be stored on Client side or Server side?

I am very open to suggestions about other resources to consume for my general edification.

Thank you for the help!

I'm still a beginner, so take my advice with a grain of salt and prioritize anything that conflicts with it over what my experience says.

  • What is the best practice in C++ for storing the players character data. Do you serialize with json or another method? Does one store it in a binary or .txt file in the program directory?

json, xml, txt, doesn't really matter as long as the serializing/deserializing is optimized.

  • Do I use a database connection to store the players character information?

Design decision. Depends on the needs of your game.

  • What is the best data structure type to use for this application since the "players" will be mixed data types. (Vector array? List? Struct?)

The structure itself is more about optimizing access and storage. Inheritance should cover the issue of multiple types in the same structure.

  • Should the character information be stored on Client side or Server side?

Again, it's a design decision. It *should* be stored on the server side to reduce user meddling (eg. Splatoon stores its competitive data on the client-side, allowing players to manipulate their online ranks by messing with their save data), but that depends on the architecture and needs of your game.

Advertisement

I have some experience with programming in python but not in C++. I have just encountered the idea of the Component Entity Systems model of design

I would recommend you get used to working in C++ before you throw in the added complexity of trying to work with component-based entities.

What is the best practice in C++ for storing the players character data. Do you serialize with json or another method? Does one store it in a binary or .txt file in the program directory?

There's no standard. JSON is not as convenient as it is in Python because C++ data structures tend not to be all dicts and lists like Python, and therefore they don't translate neatly into JSON. However, if you want to use JSON, that will work - just be aware that it's a bit more of a hassle in C++.

Usually it's not possible to write data to the program directory at run time - users will have a data directory that you can write to, the location of which depends on the platform.

Do I use a database connection to store the players character information?

If your game has a central server, then that server could potentially do that. But in that case, you might not want to use JSON since you'll have a database and could have a proper DB schema for that data.

It's not clear why you're talking about writing player data to the player's program directory one minute, then saving it on a server the next. Is this a single-player game or a multi-player game, and what data are you expecting to store where?

What is the best data structure type to use for this application since the "players" will be mixed data types

The application itself will probably have tons of different data structures. And what you use in memory doesn't necessarily have any bearing on what you'd be storing on disk. You'll need to be more specific here about what you think the problem is, because there's no standard solution we can point you at. One thing that is certain is that you will need to consider the division between data that changes during play and static data that does not.

Component Entity Systems are not easy to create, you got to think about the design before implementing. If you're new to C++ and not familiar with inheritance, casting between types etc. this would be a massive undertaking. Just think about how would these different component types interact with each other and this would depend on what other components a object has.

What is the best practice in C++ for storing the players character data. Do you serialize with json or another method? Does one store it in a binary or .txt file in the program directory?

There isn't a standard way to read JSON with C++, if you're new to C++ programmer I would start off with just trying to read from a .txt file. Structure this file to mirror your player's character data structure. For example, if your character data stores health and ammo you can represent this in the .txt file with health on the first line and ammo on the second line. Once you have this working you can start to look at more complex ways of reading/writing files (i.e. binary format).

Do I use a database connection to store the players character information?

If you're planning to make a multi-player/web based game then maybe. You could store this data in a file on the client side or server side, but think about how this would affect your design. If client side, clients could edit this data but is that a problem for your game? If it's a single player game, I'm not sure why you would want a database for this, you could just save this data to a file. C++ doesn't connect to databases as easily as other likes (i.e. PHP), so you would probability need to find a library to do this.

What is the best data structure type to use for this application since the "players" will be mixed data types. (Vector array? List? Struct?)

Comes down to your design, if you go with a Component Entity system (like Unity) everything is a GameObject, so your character could inherit from GameObject or could just be a GameObject with certain components that you think you need for a character (i.e. transform, camera, mesh renderer etc.). If they are all GameObjects or derived from GameObject you can have a vector of GameObjects.

Thank you everyone for your amazing replies! I am considering my responses and will post as soon as I have a plan of action worked out.

:-)

This topic is closed to new replies.

Advertisement