diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/players.h | 4 | ||||
| -rw-r--r-- | include/protocol.h | 48 | ||||
| -rw-r--r-- | include/zombies.h | 5 |
3 files changed, 48 insertions, 9 deletions
diff --git a/include/players.h b/include/players.h index cd7560f..ea12a96 100644 --- a/include/players.h +++ b/include/players.h @@ -19,12 +19,12 @@ typedef struct t_player { float gun_height; } player; -int my_id = 1; +u32 my_id = 1; int max_players = 10; player players[10] = {0}; -player get_player_by_id(int id); +player* get_player_by_id(u32 id); void draw_players_at_tile(platform_window* window, int x, int y); void draw_bullets(platform_window* window); float get_player_size(platform_window* window); diff --git a/include/protocol.h b/include/protocol.h index 316a21f..989c4d5 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -6,17 +6,21 @@ typedef enum t_network_message_type { MESSAGE_GET_ID_UPSTREAM, MESSAGE_GET_ID_DOWNSTREAM, + MESSAGE_USER_LIST, + MESSAGE_USER_MOVED, + MESSAGE_USER_LOOK, + MESSAGE_ZOMBIE_LIST, } network_message_type; -typedef struct t_protocol_generic_message { - network_client client; - network_message_type type; -} protocol_generic_message; - typedef struct t_protocol_generic_client_message { network_message_type type; } protocol_generic_client_message; +typedef struct t_protocol_generic_message { + network_client client; + protocol_generic_client_message *message; +} protocol_generic_message; + typedef struct t_protocol_get_id_upstream { network_message_type type; } protocol_get_id_upstream; @@ -26,10 +30,44 @@ typedef struct t_protocol_get_id_downstream { u32 id; } protocol_get_id_downstream; +typedef struct t_protocol_user_list { + network_message_type type; + player players[10]; +} protocol_user_list; + +typedef struct t_protocol_zombie_list { + network_message_type type; + zombie zombies[20]; +} protocol_zombie_list; + +typedef enum t_protocol_move_type { + MOVE_UP, + MOVE_DOWN, + MOVE_LEFT, + MOVE_RIGHT, +} protocol_move_type; + +typedef struct t_protocol_move { + network_message_type type; + protocol_move_type move; + u32 id; +} protocol_move; + +typedef struct t_protocol_user_look { + network_message_type type; + u32 id; + float gunx; + float guny; +} protocol_user_look; + #define MAX_NETWORK_BUFFER_SIZE 50000 u8 network_buffer[50000]; network_message create_protocol_get_id_up(); network_message create_protocol_get_id_down(u32 id); +network_message create_protocol_user_list(); +network_message create_protocol_user_moved(protocol_move_type move, u32 id); +network_message create_protocol_user_look(u32 id, float gunx, float guny); +network_message create_protocol_zombie_list(); array messages_received_on_server; array messages_received_on_client; diff --git a/include/zombies.h b/include/zombies.h index a8a58fe..f5df00e 100644 --- a/include/zombies.h +++ b/include/zombies.h @@ -16,6 +16,7 @@ typedef struct t_zombie { array next_path; float time_since_last_path; pathfinding_request request; + vec2f next2tiles[2]; } zombie; typedef struct t_spawner { @@ -29,8 +30,8 @@ spawner spawner_tiles[2] = { {3, 8, 999}, }; -zombie zombies[50] = {0}; -int max_zombies = 50; +zombie zombies[20] = {0}; +int max_zombies = 20; void draw_spawners(platform_window* window); void draw_zombies_at_tile(platform_window* window, int x, int y); |
