The NEW Pong Game V13.2.1
An interesting implemnettaion of the pong game
Loading...
Searching...
No Matches
network.hpp
Go to the documentation of this file.
1#ifndef NETWORK_MANAGER_HPP
2#define NETWORK_MANAGER_HPP
3
4#include <SDL_net.h>
5#include <string>
6
7struct PaddleState {
8 float y_position;
11};
12
14public:
17
18 bool init_as_host(int port = 1234);
19 bool init_as_client(const char* host, int port = 36000);
20 void send_paddle_state(const PaddleState& state);
22 void close();
23
24private:
25 UDPsocket socket;
26 IPaddress peer_address;
27 UDPpacket* send_packet;
28 UDPpacket* receive_packet;
29 bool is_host;
30};
31
32#endif
Definition network.hpp:13
void close()
Definition network.cpp:73
UDPsocket socket
Definition network.hpp:25
~NetworkManager()
Definition network.cpp:15
bool init_as_client(const char *host, int port=36000)
Definition network.cpp:32
bool init_as_host(int port=1234)
Definition network.cpp:20
NetworkManager()
Definition network.cpp:3
void send_paddle_state(const PaddleState &state)
Definition network.cpp:50
bool receive_paddle_state(PaddleState &state)
Definition network.cpp:59
IPaddress peer_address
Definition network.hpp:26
bool is_host
Definition network.hpp:29
UDPpacket * send_packet
Definition network.hpp:27
UDPpacket * receive_packet
Definition network.hpp:28
Definition network.hpp:7
bool up_pressed
Definition network.hpp:9
float y_position
Definition network.hpp:8
bool down_pressed
Definition network.hpp:10