summaryrefslogtreecommitdiff
path: root/lib/snapshot.h
diff options
context:
space:
mode:
authorJoel Stålnacke <joel@saker.fi>2025-07-26 21:09:26 +0300
committerJoel Stålnacke <joel@saker.fi>2025-07-26 21:09:26 +0300
commit63506e59366acddf4a9e017ad8aebeadcf58c164 (patch)
tree2fa106661b85497fc1d63b7743a78e523ab48fba /lib/snapshot.h
parent53f68bb7b0dce309723675c4b97f726a469031c0 (diff)
Old changesHEADmaster
Diffstat (limited to 'lib/snapshot.h')
-rw-r--r--lib/snapshot.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/snapshot.h b/lib/snapshot.h
new file mode 100644
index 0000000..022d989
--- /dev/null
+++ b/lib/snapshot.h
@@ -0,0 +1,39 @@
+#include "types.h"
+#include "constants.h"
+
+enum {
+ STATE_INACTIVE = 0,
+ STATE_ACTIVE,
+ STATE_REMOVED,
+ STATE_DEAD
+};
+
+struct player {
+ uint8_t state;
+ uint8_t input;
+ char pad[2];
+ vec2 pos;
+ vec2 vel;
+};
+
+struct ball {
+ uint8_t state;
+ vec2 pos;
+ vec2 vel;
+};
+
+struct snapshot {
+ char active;
+ uint32_t tick;
+ struct player players[WORLD_MAX_PLAYERS];
+ struct ball balls[WORLD_MAX_BULLETS];
+};
+
+int dp_snapshot_put_player(struct snapshot *, uint32_t id, const struct player *);
+struct player *dp_snapshot_get_player(struct snapshot *, uint32_t id);
+int dp_snapshot_remove_player(struct snapshot *, uint32_t id);
+int dp_snapshot_set_player_input(struct snapshot *, uint32_t id, uint8_t input);
+
+int dp_snapshot_put_ball(struct snapshot *, uint32_t id, const struct ball *);
+struct ball *dp_snapshot_get_ball(struct snapshot *, uint32_t id);
+int dp_snapshot_remove_ball(struct snapshot *, uint32_t id);