2023-07-02 13:23:07 +01:00
|
|
|
#ifndef CSPT_STATE_H
|
|
|
|
#define CSPT_STATE_H
|
|
|
|
#include <time.h>
|
|
|
|
#include <stdbool.h>
|
2023-07-12 01:12:18 +01:00
|
|
|
#include <sys/time.h>
|
2023-07-02 23:08:59 +01:00
|
|
|
#include <netinet/in.h>
|
2023-07-02 13:23:07 +01:00
|
|
|
struct clientMovement
|
|
|
|
{
|
|
|
|
double xPosition, yPosition, xVelocity, yVelocity;
|
|
|
|
bool leftAcceleration, rightAcceleration, upAcceleration, downAcceleration, registered;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct clientInput
|
|
|
|
{
|
2023-07-06 00:22:59 +01:00
|
|
|
int clientNumber;
|
2023-07-02 13:23:07 +01:00
|
|
|
bool left, right, up, down;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gameState
|
|
|
|
{
|
2023-07-12 01:12:18 +01:00
|
|
|
struct timeval timestamp;
|
2023-07-02 13:23:07 +01:00
|
|
|
struct clientMovement clients[16];
|
|
|
|
};
|
|
|
|
|
2023-07-02 23:08:59 +01:00
|
|
|
struct networkThreadArguments
|
|
|
|
{
|
|
|
|
int * clientSockets;
|
|
|
|
struct gameState * state;
|
|
|
|
};
|
|
|
|
|
2023-07-06 00:22:59 +01:00
|
|
|
void updateInput(struct gameState * state, struct clientInput * message);
|
2023-07-02 23:08:59 +01:00
|
|
|
|
2023-07-02 13:23:07 +01:00
|
|
|
void doGameTick(struct gameState * state);
|
|
|
|
|
|
|
|
#endif
|