Added a boolean field to the struct, to indicate whether the game should be quit or not
This commit is contained in:
@@ -6,17 +6,19 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Struct used to hold the data that will be sent between sockets */
|
||||
typedef struct {
|
||||
uint16_t pad_x;
|
||||
uint16_t pad_y;
|
||||
uint16_t ball_x;
|
||||
uint16_t ball_y;
|
||||
uint16_t pad_x; // X-coordinate of sending paddle
|
||||
uint16_t pad_y; // Y-coordinate of sending paddle
|
||||
uint16_t ball_x; // X-coordinate of ball (only the server fills this in)
|
||||
uint16_t ball_y; // Y-coordinate of ball (only the server fills this in)
|
||||
bool should_quit; // Flag to indicate whether game should be quit or not
|
||||
} Serial_Data;
|
||||
|
||||
/* Create a Serial_Data struct from float values */
|
||||
Serial_Data Serial_create_data(float pad_x, float pad_y, float ball_x, float ball_y);
|
||||
Serial_Data Serial_create_data(float pad_x, float pad_y, float ball_x, float ball_y, bool should_quit);
|
||||
|
||||
/* Serialize a struct into a byte array, that can be sent through a socket */
|
||||
uint8_t* Serial_serialize(Serial_Data data);
|
||||
|
Reference in New Issue
Block a user