about summary refs log tree commit diff
path: root/structs.hpp
diff options
context:
space:
mode:
authorManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2020-06-02 20:53:46 +0000
committerManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2020-06-02 20:53:46 +0000
commitb7b3d05512165e4db9142cdbc64805246909357f (patch)
treee842ac261b5e08e027c51e6c8e0ec53dac8ef097 /structs.hpp
downloadtest-multiplayer-game-b7b3d05512165e4db9142cdbc64805246909357f.tar.gz
test-multiplayer-game-b7b3d05512165e4db9142cdbc64805246909357f.tar.bz2
test-multiplayer-game-b7b3d05512165e4db9142cdbc64805246909357f.zip
Release
Diffstat (limited to 'structs.hpp')
-rw-r--r--structs.hpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/structs.hpp b/structs.hpp
new file mode 100644
index 0000000..94a65b7
--- /dev/null
+++ b/structs.hpp
@@ -0,0 +1,60 @@
+enum class PacketType
+{
+	packet_connect,
+	packet_disconnect,
+	packet_move,
+	packet_ping,
+	packet_server_info
+};
+
+struct Player 
+{
+	unsigned int sender_id;
+	int fd;
+	char name[20];
+	char ip[20];
+	int x, y;
+	int color;
+	bool is_color;
+};
+
+struct PacketConnect
+{
+	Player player;
+};
+
+struct PacketDisconnect
+{
+	Player player;
+};
+
+struct PacketMove
+{
+	Player player;
+	int x, y;
+       	bool is_color;	
+};
+
+struct PacketPing
+{
+};
+
+struct PacketServerInfo
+{
+	int max_players;
+	int fps;
+};
+
+struct Packet
+{
+	PacketType type;
+	unsigned int sender_id;
+	union
+	{
+		PacketConnect packet_connect;
+		PacketDisconnect packet_disconnect;
+		PacketMove packet_move;
+		PacketPing packet_ping;
+		PacketServerInfo packet_server_info;
+	} data;
+};