Platform Data Engine 0.0.1
A data-driven game engine for platformers
|
How networking works: The server will spawn the entire world and start a simulation, it will send out spawn game object packets to all of it's clients to replicate the same world on their computers, the server will then spawn player game objects for each client that is connected and send out "BindPlayer" packets to the clients, this will tell the client which game object it is controlling (for things like the camera controller) More...
#include <Packet.h>
Public Types | |
enum | PFlag { None , Ping , Pong , Connect , Disconnect , Connected , Disconnected , Text , SetObjectHealth , RequestUpdates , SendUpdates , UserInput } |
Public Member Functions | |
PDEPacket () | |
PDEPacket (PFlag) | |
void | setFlag (PFlag) |
PFlag | flag () const |
sf::Uint8 | flagAsU () const |
bool | isFlagged () const |
virtual void | clear () |
How networking works: The server will spawn the entire world and start a simulation, it will send out spawn game object packets to all of it's clients to replicate the same world on their computers, the server will then spawn player game objects for each client that is connected and send out "BindPlayer" packets to the clients, this will tell the client which game object it is controlling (for things like the camera controller)
When a client gets user input, instead of updating the position of it's local game object, since it's a client, it will send a "UserInput" packet to the server, the server will simulate 1 step of input and send the resulting game object positions and any other relavent data to the client
So in this system, the server is completely authoritative, the clients will simply be puppeted by the server and the inputs they send to the server will simply be Button or Axis values that the server will interperate and send position data back for.
Enumerates the possible flags a packet can have. It will be automatically sent and received when using this class for sharing data across sockets. Feel free to extend this enumeration to match your need.
PDEPacket::PDEPacket | ( | ) |
Default constructor.
PDEPacket::PDEPacket | ( | PFlag | flag | ) |
Overloaded constructor. Constructs a Packet and sets the flag as specified.
|
virtual |
Hiding base class clear() function. Clears the packet as usual and sets the flag to 'None', so isFlagged() will return false.
|
inline |
Reads the flag.
|
inline |
Reads the flag as an 8 bytes unsigned int.
|
inline |
Checks if a flag has been set on this Packet. Returns false if flag equals to PDEPacket::None.
void PDEPacket::setFlag | ( | PFlag | flag | ) |
Sets the flag to the packet