diff options
| author | Aldrik Ramaekers <aldrik@amftech.nl> | 2023-12-26 23:47:45 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik@amftech.nl> | 2023-12-26 23:47:45 +0100 |
| commit | 8b866546c9c939a61c8a6f762e71fe0c7246bef8 (patch) | |
| tree | f3493bad7ab55c37e1c5e0442a013b4b9fd466ac | |
| parent | ddcd60881a73860c9c4d4dd895196221dfdd4aef (diff) | |
gun work
| -rw-r--r-- | build/zombies.exe | bin | 2110646 -> 2110612 bytes | |||
| -rw-r--r-- | include/players.h | 2 | ||||
| -rw-r--r-- | src/objects.c | 2 | ||||
| -rw-r--r-- | src/players.c | 4 |
4 files changed, 5 insertions, 3 deletions
diff --git a/build/zombies.exe b/build/zombies.exe Binary files differindex 797eebd..0b4dd5c 100644 --- a/build/zombies.exe +++ b/build/zombies.exe diff --git a/include/players.h b/include/players.h index 44cf8b1..6aa5b88 100644 --- a/include/players.h +++ b/include/players.h @@ -14,6 +14,8 @@ #define MAX_PLAYERS 10 #define MAX_POINT_ANIMATIONS 10 +#define GUN_OFFSET_FROM_PLAYER 0.8f + typedef enum t_player_interact_state { INTERACT_IDLE, INTERACT_RELOADING, diff --git a/src/objects.c b/src/objects.c index fad613b..32a2dc7 100644 --- a/src/objects.c +++ b/src/objects.c @@ -137,6 +137,6 @@ void create_objects() { create_spawner((vec2){15, 5}); create_spawner((vec2){3, 8}); */ - //create_spawner((vec2){11, 18}); + create_spawner((vec2){11, 18}); create_wallitem((vec3f){14, 1, 0}, WALLITEM_GUN, (wall_item_data){.gun = GUN_NOVA}); }
\ No newline at end of file diff --git a/src/players.c b/src/players.c index fc3e050..3122af2 100644 --- a/src/players.c +++ b/src/players.c @@ -466,7 +466,7 @@ void draw_player(platform_window* window, player* p, int index) { float player_render_x = player_pos.x; float player_render_y = player_pos.y; - vec2f gun_pos = world_pos_to_screen_pos(window, p->gunx, p->guny, p->gun_height); + vec2f gun_pos = world_pos_to_screen_pos(window, p->gunx - (p->dirx*GUN_OFFSET_FROM_PLAYER), p->guny - (p->diry*GUN_OFFSET_FROM_PLAYER), p->gun_height); float gun_size = info.tile_width * get_gun_size(p->guntype); // Gun @@ -476,7 +476,7 @@ void draw_player(platform_window* window, player* p, int index) { float rads = -atan2(p->diry, p->dirx); renderer->render_set_rotation(rads); - log_infox("%f", rads); + vec2f tl = (vec2f){0.0f, 0.0f}, tr = (vec2f){1.0f, 0.0f}, bl = (vec2f){0.0f, 1.0f}, br = (vec2f){1.0f, 1.0f}; if (rads > M_PI/2 || rads < -M_PI/2) { tl = (vec2f){1.0f, 0.0f}; |
