Repository navigation
Scene Configuration
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)
- Having a user-friendly system (By reading the documentation, a user should be able to modify or create its own game configuration)
For both client and server, make sure to go in this folder: Game/GameData/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.
Each configuration file is written the same way. Here's an example of a file:
{
"keyBinds": [
],
"entities": [
],
"systems": [
],
"eventHandlers": [
],
"networkUpdate": [
],
"menus": {
"keyBinds": [
]
},
"music": "",
"sounds": [
]
}Note that the menus field isn't taken in account by the server side.
In this file, you can see 8 parts:
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 Key-map)
-
A Path:
- The type of system that an input should run (For example, pressing Z can run the "move" system)
- The name of another configuration file.
To defines key binds, just list all the keys and all the systems in a list of json objects:
{
"keyBinds": [
{
"key": "KEY_W",
"path" : "libsystem_moveUp.so"
},
{
"key": "KEY_SPACE",
"path": "libsystem_shoot.so"
},
...
]
}Obviously, you can create as many key binds as you want In the limit of physical key binds.
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
- Colour
- Direction
- etc...
So, to define entities, just list initialization systems of the entities you want:
{
"entities": [
"libsystem_initBackground.so",
...
]
} A system is a function that modifies components of entities. To see more details about systems, check here.
All the systems will be run every game loop.
To defines systems, just list all the systems in the same list:
{
"systems": [
"libsystem_moveEntities.so",
"libsystem_shootDestroy.so",
...
]
}An event handler is a function that modifies components of entities and other app modules, like the network. To see more details about systems, check here.
All the event handlers will be run if an event of the same type is in the queue of events.
To defines event handlers, just list all ones in the same list:
{
"systems": [
"libeventHandler_UpdateCamera.so",
"libeventHandler_InitHitBox.so",
...
]
}The network updates part contains a list of objects, where each object links a component to a system.
These systems are used when the server sends updates to the client. If the update concerns a component that is listed in this object, the client will trigger the linked system.
Here's an example of a scene with nothing except network updates:
{
"networkUpdate": [
{
"component": "Position2DComponent",
"path": "libupdate_position_component.so"
},
...
]
}
The menus part only contains key binds to swap to menus.
Since the server has no menus, the server can't read this part.
In the key binds of the menus part, you can only put keys that links to menus json files.
For example, if you want a scene with nothing except a key bind to swap to a menu, you can do this:
{
"menus": {
"keyBinds": [
{
"key": "KEY_SPACE",
"path": "nextMenu.json"
},
...
]
}
}
This field is very simple, just fill a music, and it will be played if the right handlers are present too.
Here's an example
{
"music": "Assets/Musics/InGame.wav"
}A sound is basically a noise that last a short amount of time (Like the noise of a shoot). Here, you can list all the sounds and when do they need to be played
Here's an example of how you can add sounds:
{
"sounds": [
{
"key": "MOUSE_LEFT_CLICK",
"path": "Assets/Sounds/ui-pop.mp3"
}
]
}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) (Has to be put in key binds part)
There are systems that can be run at any time, like the "display", which can be call every second to display for example. (Has to be put in systems part)
There are systems that initialize entities, which are run only one time. (Has to be put in entities part)
There are also event handlers, that are systems that executes only when triggered by an event.
Basically, to create a new scene, fill your json file with this:
{
"keyBinds": [
],
"entities": [
],
"systems": [
],
"eventHandlers": [
],
"networkUpdate": [
],
"menus": {
"keyBinds": [
]
},
"music": "",
"sounds": [
]
}
This is the base of a scene, then, you can just add key binds, entities, systems, etc... as you wish for your scene.
Don't forget to check all other documentation to be able to create your own scene.