Skip to content

Commit cdaa0bb

Browse files
authored
Merge pull request #121 from maelbecel/docs
Docs
2 parents dc96705 + 479cfd2 commit cdaa0bb

28 files changed

+1795
-31
lines changed

doc/Writerside/hi.tree

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,34 @@
2222
<toc-element topic="CONTRIBUTING.md">
2323
<toc-element topic="CODE-OF-CONDUCT.md"/>
2424
</toc-element>
25-
<toc-element topic="Server.md"/>
26-
<toc-element topic="Client.md"/>
25+
<toc-element topic="Server.md">
26+
<toc-element topic="server-user.md"/>
27+
<toc-element topic="server-server.md"/>
28+
<toc-element topic="server-main.md"/>
29+
</toc-element>
30+
<toc-element topic="Client.md">
31+
<toc-element topic="client-rtype.md">
32+
<toc-element topic="client-system.md"/>
33+
<toc-element topic="client-scripts.md">
34+
<toc-element topic="client-scripts-star.md"/>
35+
<toc-element topic="client-scripts-player.md"/>
36+
<toc-element topic="client-scripts-pata-pata.md"/>
37+
<toc-element topic="client-scripts-bullet-ennemy.md"/>
38+
<toc-element topic="client-scripts-bullet-player.md"/>
39+
</toc-element>
40+
<toc-element topic="client-event.md"/>
41+
<toc-element topic="client-component.md">
42+
<toc-element topic="client-health.md"/>
43+
<toc-element topic="client-clock.md"/>
44+
<toc-element topic="client-animation.md"/>
45+
</toc-element>
46+
<toc-element topic="client-scene-type.md"/>
47+
<toc-element topic="client-r-type.md"/>
48+
</toc-element>
49+
<toc-element topic="client-client.md">
50+
<toc-element topic="client-layer.md"/>
51+
</toc-element>
52+
</toc-element>
2753
<toc-element topic="Game-Engine.md">
2854
<toc-element topic="Exodia.md">
2955
<toc-element topic="Script.md">

doc/Writerside/topics/Client.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
# Client
22

3-
Client documentation will come soon
3+
The client is the part of the game that is used by the player.
4+
5+
It is divided in 2 parts :
6+
7+
- [Client](client-client.md) : The part that allow to create a client.
8+
- [RType](client-rtype.md) : The part that allow to create the R-Type.

doc/Writerside/topics/Header.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,26 @@ value = swapEndianness(value);
2222
std::cout << std::hex << value << std::endl;
2323
```
2424

25+
## Command
26+
27+
The commands from the server to the client are the following:
28+
29+
| Code | Command | Description |
30+
|------|------------------|------------------------------------------------|
31+
| 0x00 | PACKET_INFO | Used to send the information about the packet. |
32+
| 0x01 | ACK | Used to acknowledge a packet. |
33+
| 0x02 | CONNECT_ACCEPT | Used to accept a connection. |
34+
| 0x03 | CONNECT_REJECT | Used to refuse a connection. |
35+
| 0x0B | SYSTEM_LOAD | Used to load a system. |
36+
| 0x0C | COMPONENT_OF | Used to get the components of an entity. |
37+
| 0x0D | GAME_EVENT | Used to send game events |
38+
| 0x0E | DELETE_ENTITY | Used to delete an entity. |
39+
| 0x0F | DELETE_COMPONENT | Used to delete a component. |
40+
| 0x10 | IMPORTANT_EVENT | Used to send important events. |
41+
| 0x81 | CONNECT | Used to connect to the server. |
42+
| 0x82 | DISCONNECT | Used to disconnect from the server. |
43+
| 0x8B | EVENT | Used to send events. |
44+
2545
## Constructor
2646

2747
```c++

doc/Writerside/topics/Home.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Welcome to the RType Game Engine documentation! RType is an exciting game engine
1111
4. [Architecture](#architecture)
1212
1. [Entity-Component-System (ECS)](#entity-component-system-ecs)
1313
2. [Modules](#modules)
14-
5. [Example](#example)
14+
5. [Example](#examples)
1515
6. [Contributing](#contributing)
1616
7. [Contact](#contact)
1717

doc/Writerside/topics/Network.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ He is divided in 5 parts:
1111

1212
The Network class is the main class of the Network module. It contains the methods that will be used to initialize the Network module.
1313

14+
### NetworkType
15+
16+
```c++
17+
enum NetworkType {
18+
NONE,
19+
CLIENT,
20+
SERVER,
21+
SINGLEPLAYER
22+
};
23+
```
24+
25+
It's an enum that contains the different types of network.
26+
1427
### Constructor
1528

1629
```c++

doc/Writerside/topics/Server.md

Lines changed: 89 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The server is the core of the game. It manages the game logic and the network.
77
1. [RFC](#rfc)
88
- [What is an RFC?](#what-is-an-rfc)
99
- [Actual RFC for the Server](#actual-rfc-for-the-server)
10+
2. [Actual server](#actual-server)
1011

1112
## RFC
1213

@@ -21,7 +22,7 @@ The RFC for the Server is :
2122
```text
2223
Exodia
2324
Request for comments: 1
24-
29 november 2023
25+
31 december 2023
2526
Author: Axel Rohee
2627
2728
@@ -65,11 +66,11 @@ Content_of_a_component - 32 bit (4 bytes) unsigned integer representing the
6566
length of the content followed by the content.
6667
System - Null terminated string prefixed with a 32 bit (4 bytes) unsigned
6768
integer representing the length of the string.
68-
Timestamp - 32 bit (4 bytes) float representing the time in seconds.
69+
Timestamp - 64 bit (8 bytes) float representing the time in seconds.
6970
Event - 32 bit (4 bytes) unsigned integer representing the event type.
7071
Id - 64 bit (8 bytes) unsigned integer representing the id of the command
7172
use for implementing acknoledgement.
72-
GameEvents - - Null terminated string prefixed with a 32 bit (4 bytes) unsigned
73+
GameEvents - Null terminated string prefixed with a 32 bit (4 bytes) unsigned
7374
integer representing the length of the string.
7475
Size - 64 bit (8 bytes) unsigned integer representing the size of the content
7576
of the packet.
@@ -79,8 +80,16 @@ Commands
7980
Each command is prefixed with a header define below representing the command. There are the
8081
following commands command inferior to 0x80 are server commands and superior
8182
to 0x80 are client commands.
83+
The header is composed of the following:
84+
Command - 8 bits (1 byte) bitfield representing the command number.
85+
Timestamp - 32 bit (4 bytes) float representing the time in seconds.
86+
Id - 64 bit (8 bytes) unsigned integer representing the id of the command.
87+
Size - 64 bit (8 bytes) unsigned integer representing the size of the content
88+
of the packet.
89+
Bool - 1 bit represnting if the command is important or not.If it needs an acknowledge or not.
90+
8291
Header
83-
Content: [Command][Timestamp][Id][Size]
92+
Content: [Command][Timestamp][Id][Bool][Size]
8493
8594
Special commands
8695
0x00 - Send number of packets received and send since last second
@@ -89,33 +98,84 @@ Special commands
8998
Content: [Id]
9099
ServerCommand
91100
0x02 - Accept client connection
101+
Content: [Id]
92102
0x03 - Reject client connection
93-
0x0b - Send system to load MUST get an acknowledge
94-
Content: [System][System]...
95-
0x0c - Send entities with their components MUST get an acknowledge
103+
0x0b - Send system to load
104+
Content: [System]
105+
0x0c - Send entities with their components
96106
Content: [Entity][Component][Content_of_a_component]
97-
0x0d - Send GameEvents MUST get an acknowledge
98-
Content: [GameEvents][GameEvents]...
99-
0x0e - Send deleted entities MUST get an acknowledge
107+
0x0d - Send GameEvents
108+
Content: [GameEvents]
109+
0x0e - Send deleted entities
100110
Content: [Entity]
101-
0x10 - Send deleted components on entities MUST get an acknowledge
111+
0x0f - Send deleted components on entities
102112
Content: [Entity][Component][Content_of_a_component]
103-
0x11 - Send events
104-
Content: [Event]
105113
ClientCommand
106-
0x81 - Connect MUST get an acknowledge
114+
0x81 - Connect
115+
Content: [Timestamp][Id]
107116
0x82 - Disconnect
108-
0x8a - Send events
109-
Content: [Event]
110-
0x8b - Send important events MUST get an acknowledge
111-
Content: [Event]
117+
0x8b - Send events release the bool is true if the event is a key press false if it is a key release
118+
Content: [Event][Bool]
119+
120+
Details
121+
122+
0x00 - Packet info
123+
This command is used to send the number of packets received and send since
124+
last call of this command. This command is used to calculate the packet loss
125+
It's content is [Int][Int] the first int is the number of packets received
126+
and the second int is the number of packets send.
127+
128+
0x01 - Acknowledge
129+
This command is used to acknowledge a command. It's content is [Id] the id
130+
of the command to acknowledge.
131+
132+
0x02 - Accept client connection
133+
This command is used to accept a client connection.
134+
It's content is [Id] the id of the client.
135+
136+
0x03 - Reject client connection
137+
This command is used to reject a client connection. It's content is empty.
138+
139+
0x0b - Send system to load
140+
This command is used to send the systems to load. It's content is
141+
[System] the system to load.
142+
143+
0x0c - Send entities with their components
144+
This command is used to send the entities with one components. It's
145+
content is [Entity][Component][Content_of_a_component] the entity to load
146+
the component to load and the content of the component.
147+
148+
0x0d - Send GameEvent
149+
This command is used to send the GameEvents. It's content is
150+
[GameEvents] the GameEvents to load.
151+
152+
0x0e - Send deleted entities
153+
This command is used to send the deleted entities. It's content is
154+
[Entity] the entity to delete.
155+
156+
0x0f - Send deleted components on entities
157+
This command is used to send the deleted components on entities. It's
158+
content is [Entity][Component] the entity to delete
159+
the component to delete and the content of the component to delete.
160+
161+
0x81 - Connect
162+
This command is used to connect to the server. It's content is
163+
[Timestamp][Id] the timestamp of the client and the id of the server to
164+
connect to.
165+
166+
0x82 - Disconnect
167+
This command is used to disconnect from the server. It's content is empty.
168+
169+
0x8b - Send events
170+
This command is used to send the events. It's content is [Event][Bool] the event
171+
to send and a bool representing if the event is a key press or a key release.
112172
113173
Usage
114174
115175
The protocol is designed to be used in a certain way.
116176
this section will show an example of how to use the protocol.
117177
118-
Initiation:events
178+
Initiation:
119179
Client -> [0x81][Timestamp][Id]
120180
Server -> [0x02][Timestamp][Id]
121181
Server -> [0x0b][Timestamp][Id][System][System]...
@@ -136,4 +196,13 @@ End:
136196
one or the other:
137197
Client -> [0x82][Timestamp][Id][Id] and Server -> [0x11][Timestamp][Id][Id]
138198
Server -> [0x03][Timestamp][Id]
139-
```
199+
200+
```
201+
202+
## Actual server
203+
204+
The R-Type server is divide in 3 parts :
205+
- [Main](server-main.md) : The main of the server.
206+
- [Server](server-server.md) : The part that allow to create a server.
207+
- [User](server-user.md) : The part to handle the users.
208+

doc/Writerside/topics/UDPWrapper.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ The **`UDPSocket`** class encapsulates UDP socket functionality for network comm
88
- Enables flexible handling of data transmission between game clients.
99

1010
### Usage
11-
```cpp
11+
12+
```c++
1213
class UDPSocket {
1314
public:
1415
// Constructor
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Animation
2+
3+
The Animation component is used to animate sprites.
4+
5+
It has multiple properties :
6+
7+
| Property | Type | Description |
8+
|---------------------|----------------------------------------------|-------------------------------------|
9+
| `Frames` | `std::vector\<Ref\<Exodia::SubTexture2D\>\>` | The frames of the animation. |
10+
| `IsPlaying` | `bool` | If the animation is playing. |
11+
| `Repeat` | `bool` | If the animation should repeat. |
12+
| `FrameRate` | `float` | The frame rate of the animation. |
13+
| `FrameTimer` | `float` | The frame timer of the animation. |
14+
| `CurrentFrameIndex` | `int` | The current frame of the animation. |
15+
16+
## Constructor
17+
18+
```c++
19+
AnimationComponent(const AnimationComponent &other)
20+
: Frames(other.Frames), IsPlaying(other.IsPlaying), Repeat(other.Repeat), FrameRate(other.FrameRate),
21+
FrameTimer(other.FrameTimer), CurrentFrameIndex(other.CurrentFrameIndex){};
22+
23+
AnimationComponent(const std::vector<Ref<Exodia::SubTexture2D>> &frames = {})
24+
: Frames(frames), IsPlaying(false), Repeat(false), FrameRate(0.0f), FrameTimer(0.0f),
25+
CurrentFrameIndex(0){};
26+
```
27+
28+
The constructor of the Animation component initialize the properties of the component.
29+
30+
## DeserializeData
31+
32+
```c++
33+
void DeserializeData(Exodia::Buffer data)
34+
```
35+
36+
The `DeserializeData` function deserialize the data of the component.
37+
38+
## SerializeData
39+
40+
```c++
41+
Exodia::Buffer SerializeData()
42+
```
43+
44+
The `SerializeData` function serialize the data of the component.
45+
46+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Client
2+
3+
The client is the part of the game that is used by the player.
4+
5+
## Project
6+
7+
The `Client` contain a file with a `.proj` extension. This file is used to
8+
configure the project.
9+
10+
It contains the following lines:
11+
12+
```text
13+
Project:
14+
Name: R-Type
15+
StartScene: 7402922757700725494
16+
AssetsDirectory: "../Assets"
17+
AssetRegistryPath: "AssetRegistry.asset"
18+
ScriptsDirectory: "Scripts"
19+
```
20+
21+
It has the following properties:
22+
23+
| Name | Description |
24+
|----------------------|-----------------------------------------------------------------------------|
25+
| Name | The name of the project. |
26+
| StartScene | The id of the scene to start with. |
27+
| AssetsDirectory | The path to the assets directory. |
28+
| AssetRegistryPath | The path to the asset registry. |
29+
| ScriptsDirectory | The path to the scripts directory. |
30+
31+
## R-Type
32+
33+
The R-Type is the main part of the client.
34+
35+
First we create the `RTypeClient` class. It will create an application using the R-Type layer.
36+
37+
```c++
38+
RTypeClient(const ApplicationSpecification &spec) : Application(spec) { PushLayer(new RType::RTypeLayer()); }
39+
```
40+
41+
We also create an entry point `CreateApplication`, that will initialize the application.
42+
43+
```c++
44+
Application *CreateApplication(ApplicationCommandLineArgs args) {
45+
EXODIA_PROFILE_FUNCTION();
46+
47+
RType::InitRType();
48+
49+
ApplicationSpecification spec;
50+
51+
spec.Name = "Application Example";
52+
spec.CommandLineArgs = args;
53+
54+
return new RTypeClient(spec);
55+
}
56+
```
57+
58+
## R-Type Layer
59+
60+
The R-Type layer is the layer that will contain the game.
61+
We can see all details [here](client-layer.md).

0 commit comments

Comments
 (0)