diff options
| author | Aldrik Ramaekers <aldrik@amftech.nl> | 2022-12-15 12:59:19 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik@amftech.nl> | 2022-12-15 12:59:19 +0100 |
| commit | 7b956089e6ba5162fb0b667f1c0a60f6ece90c38 (patch) | |
| tree | 82de31240ad1f1ae77874f07b288fcc39b8948f4 /include | |
| parent | 23d2cc231e5b4c015a8471d3035dc07802de23d5 (diff) | |
added drops
Diffstat (limited to 'include')
| -rw-r--r-- | include/drops.h | 33 | ||||
| -rw-r--r-- | include/math_helper.h | 4 | ||||
| -rw-r--r-- | include/objects.h | 1 | ||||
| -rw-r--r-- | include/players.h | 5 | ||||
| -rw-r--r-- | include/protocol.h | 41 | ||||
| -rw-r--r-- | include/zombies.h | 2 |
6 files changed, 69 insertions, 17 deletions
diff --git a/include/drops.h b/include/drops.h new file mode 100644 index 0000000..e7ab661 --- /dev/null +++ b/include/drops.h @@ -0,0 +1,33 @@ +#ifndef INCLUDE_DROPS +#define INCLUDE_DROPS + +#include <projectbase/project_base.h> + +#include "guns.h" + +typedef enum t_drop_type { + DROP_GUN, + DROP_AMMO, +} drop_type; + +typedef struct t_drop { + bool active; + float time_active; + vec3f position; + vec3f size; + float start_h; + drop_type type; + union { + int ammo_count; + gun_type gun; + } data; +} drop; + +#define MAX_DROPS 50 +drop drops[MAX_DROPS] = {0}; + +void update_drops(); +void draw_drops(platform_window* window); +void spawn_drop(vec3f pos); + +#endif
\ No newline at end of file diff --git a/include/math_helper.h b/include/math_helper.h index b3a6cfe..ca27e14 100644 --- a/include/math_helper.h +++ b/include/math_helper.h @@ -8,6 +8,8 @@ #include "map.h" #define MAP_RENDER_DEPTH renderer->set_render_depth(1); + +#define DROP_RENDER_DEPTH(_h) renderer->set_render_depth(4 + ceil(_h)); #define BULLET_RENDER_DEPTH(_h) renderer->set_render_depth(5 + ceil(_h)); #define OBJECT_RENDER_DEPTH(_h) renderer->set_render_depth(5 + ceil(_h)); #define OVERLAY_RENDER_DEPTH() renderer->set_render_depth(100); @@ -17,6 +19,6 @@ int orientation(vec2f p, vec2f q, vec2f r); bool lines_intersect(vec2f p1, vec2f q1, vec2f p2, vec2f q2); vec2f get_intersection_point(vec2f A, vec2f B, vec2f C, vec2f D); box get_render_box_of_square(platform_window* window, vec3f position, vec3f size); -box get_box_of_square(platform_window* window, vec3f position, vec3f size); +box get_box_of_square(vec3f position, vec3f size); #endif
\ No newline at end of file diff --git a/include/objects.h b/include/objects.h index b7c14b3..04f434b 100644 --- a/include/objects.h +++ b/include/objects.h @@ -34,5 +34,6 @@ object objects[150]; void create_objects(); void draw_objects_at_row(platform_window* window, int row); box get_box_of_object(platform_window* window, object o); +void render_quad_with_outline(vec2f tl, vec2f tr, vec2f bl, vec2f br, color c); #endif
\ No newline at end of file diff --git a/include/players.h b/include/players.h index e51e4e2..ab8da4c 100644 --- a/include/players.h +++ b/include/players.h @@ -20,8 +20,11 @@ typedef struct t_player { float gun_height; int total_ammo; int ammo_in_mag; + float height; gun_type guntype; network_client client; // For the host: is_connected = false and socket = 0 + int kills; + u64 ping; } player; #include "protocol.h" @@ -35,7 +38,7 @@ player players[10] = {0}; int get_player_count(); player* get_player_by_id(u32 id); -void draw_players_at_tile(platform_window* window, int x, int y); +void draw_players(platform_window* window); void draw_bullets(platform_window* window); object check_if_player_collided_with_object(platform_window* window, player p); float get_player_size(platform_window* window); diff --git a/include/protocol.h b/include/protocol.h index 64822a2..aec65b4 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -3,7 +3,8 @@ #include <projectbase/project_base.h> -typedef enum t_network_message_type { +typedef enum t_network_message_type +{ MESSAGE_GET_ID_UPSTREAM, MESSAGE_GET_ID_DOWNSTREAM, MESSAGE_USER_LIST, @@ -14,48 +15,58 @@ typedef enum t_network_message_type { MESSAGE_BULLET_LIST, } network_message_type; -typedef struct t_protocol_generic_client_message { +typedef struct t_protocol_generic_client_message +{ network_message_type type; } protocol_generic_client_message; -typedef struct t_protocol_generic_message { +typedef struct t_protocol_generic_message +{ network_client client; protocol_generic_client_message *message; + u64 send_timestamp; } protocol_generic_message; -typedef struct t_protocol_get_id_upstream { +typedef struct t_protocol_get_id_upstream +{ network_message_type type; } protocol_get_id_upstream; -typedef struct t_protocol_get_id_downstream { +typedef struct t_protocol_get_id_downstream +{ network_message_type type; u32 id; } protocol_get_id_downstream; -typedef struct t_protocol_user_list { +typedef struct t_protocol_user_list +{ network_message_type type; player players[10]; } protocol_user_list; -typedef struct t_protocol_zombie_list { +typedef struct t_protocol_zombie_list +{ network_message_type type; zombie zombies[20]; } protocol_zombie_list; -typedef enum t_protocol_move_type { +typedef enum t_protocol_move_type +{ MOVE_UP, MOVE_DOWN, MOVE_LEFT, MOVE_RIGHT, } protocol_move_type; -typedef struct t_protocol_move { +typedef struct t_protocol_move +{ network_message_type type; protocol_move_type move; u32 id; } protocol_move; -typedef struct t_protocol_user_look { +typedef struct t_protocol_user_look +{ network_message_type type; u32 id; float gunx; @@ -64,12 +75,14 @@ typedef struct t_protocol_user_look { #include "bullets.h" -typedef struct t_protocol_bullets_list { +typedef struct t_protocol_bullets_list +{ network_message_type type; bullet bullets[500]; } protocol_bullets_list; -typedef struct t_protocol_user_shoot { +typedef struct t_protocol_user_shoot +{ network_message_type type; u32 id; float dirx; @@ -90,7 +103,7 @@ network_message create_protocol_bullets_list(); array messages_received_on_server; array messages_received_on_client; -void server_on_message_received(u8* buffer, u32 length, network_client client); -void client_on_message_received(u8* buffer, u32 length); +void server_on_message_received(u8 *buffer, u32 length, u64 timestamp, network_client client); +void client_on_message_received(u8 *buffer, u32 length); #endif
\ No newline at end of file diff --git a/include/zombies.h b/include/zombies.h index f5df00e..df5e629 100644 --- a/include/zombies.h +++ b/include/zombies.h @@ -34,7 +34,7 @@ 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); +void draw_zombies(platform_window* window); void spawn_zombie(int x, int y); #endif
\ No newline at end of file |
