Scene Configuration
Why using scene configuration files ?
Scene configuration allows the game many things:
Making an unlimited amount of levels (Server side)
Making an unlimited amount of menus (Client side)
Changing the game configuration at run time (No need to compile the game again)
Being a user-friendly system (By reading the documentation, a user should be able to modify or create its own game configuration)
How to clone the repository ?
To create configuration files, make sure to clone the repository using this command:
git clone https://github.com/FppEpitech/R-Type.gitor this one:
git clone git@github.com:FppEpitech/R-Type.gitFrom what is a configuration composed of ?
Creating the file:
For the server, make sure to go in this folder: Server/config/scenes/
For the client, make sure to go in this folder: Client/config/scenes/
Now that you're in the right folder, you can create your configuration file, create a file named as you want in this directory.
What the files are composed of ?
Each configuration file is written the same way. Here's an example of a file:
{
"keyBinds": [
{
"key": "KEY_APOSTROPHE",
"path" : ""
}
],
"entities": [
[
]
],
"systems": [
]
}
In this file, you can see 3 parts:
The key binds:
This part is an array of objects. Each object is composed of:
A Key: A string which represents a keyboard input. (You can see the correspondences here)
A Path:
- The type of a system that an input should run (For example, pressing Z can run the "move" system)
- The name of another configuration file.
Obviously, you can create as many key binds as you want In the limit of physical key binds.
The entities:
An entity is an object that is represented by a list of components. To see more details about components, check here.
For example, a wall can be represented by these components:
Position
Color
Direction
etc...
So, to define your entity, just list all the components that it needs:
{
"entities": [
[
"Position.so",
"Color.so",
"Direction.so",
...
]
]
} If you want multiple entities, just make multiple arrays of components.
The systems
A system is a function that modifies components of entities. To see more details about systems, check here.
To defines systems, just list all the systems in the same list:
{
"systems": [
"system1.so"
"system2.so"
...
]
}There are different types of systems !
There are systems that are only runnable from user inputs, like the "move" system, which can only be triggered by Z for example. (Non-exhaustive)
And there are systems that can be run at any time, like the "display", which can be call every second to display for example.
How to write your own configuration ?
To write your own configuration file, you'll need to think about which key binds do you want to set up or not, and to which action will they be linked. Either switching scene or running a system.
You'll also need to think about which entities you'll need, from which components are they going to be composed and how many you'll need.
Finally, don't forget to list all the systems of the scene.