diff options
| -rw-r--r-- | Makefile | 5 | ||||
| -rw-r--r-- | include/allocator.h | 2 | ||||
| -rw-r--r-- | include/asset_defs.h | 2 | ||||
| -rw-r--r-- | include/audio.h | 2 | ||||
| -rw-r--r-- | include/bullets.h | 2 | ||||
| -rw-r--r-- | include/drops.h | 2 | ||||
| -rw-r--r-- | include/fog_of_war.h | 8 | ||||
| -rw-r--r-- | include/game.h | 2 | ||||
| -rw-r--r-- | include/keybindings.h | 2 | ||||
| -rw-r--r-- | include/list.h | 2 | ||||
| -rw-r--r-- | include/map.h | 2 | ||||
| -rw-r--r-- | include/math_helper.h | 2 | ||||
| -rw-r--r-- | include/menu.h | 2 | ||||
| -rw-r--r-- | include/objects.h | 2 | ||||
| -rw-r--r-- | include/overlay.h | 2 | ||||
| -rw-r--r-- | include/pathfinding.h | 2 | ||||
| -rw-r--r-- | include/players.h | 2 | ||||
| -rw-r--r-- | include/protocol.h | 2 | ||||
| -rw-r--r-- | include/rounds.h | 2 | ||||
| -rw-r--r-- | include/sprite.h | 2 | ||||
| -rw-r--r-- | include/throwables.h | 2 | ||||
| -rw-r--r-- | include/wall_item.h | 2 | ||||
| -rw-r--r-- | include/zombie_chunk.h | 2 | ||||
| -rw-r--r-- | include/zombies.h | 2 | ||||
| -rw-r--r-- | libs/msvc/SDL2.dll | bin | 0 -> 1364992 bytes | |||
| -rw-r--r-- | main.c | 2 | ||||
| -rw-r--r-- | msvc.bat | 2 | ||||
| -rw-r--r-- | src/fog_of_war.c | 56 | ||||
| -rw-r--r-- | src/game.c | 1 |
29 files changed, 93 insertions, 25 deletions
@@ -4,7 +4,8 @@ main: cp -a "data/." "build/data" gcc -m64 -g -Wl,--stack,4194304 -DMODE_DEBUG main.c -o build/zombies.exe -lSDL2_mixer -lSDL2 cp -a "build/." "C:/Manually installed programs/zombieshooter" - gdb -ex run --args ./build/zombies.exe -ip 127.0.0.1 -port 27015 + #gdb -ex run --args ./build/zombies.exe -ip 127.0.0.1 -port 27015 + ./build/zombies.exe -ip 127.0.0.1 -port 27015 menu: rm -rf "build/" @@ -16,4 +17,4 @@ menu: debug_client: ./build/zombies.exe -ip 127.0.0.1 -port 27015 & - ./build/zombies.exe -ip 172.27.192.1 -port 27015
\ No newline at end of file + ./build/zombies.exe -ip 172.22.64.1 -port 27015
\ No newline at end of file diff --git a/include/allocator.h b/include/allocator.h index a1c8bf0..7ee33b2 100644 --- a/include/allocator.h +++ b/include/allocator.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_ALLOCATOR #define INCLUDE_ALLOCATOR -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" typedef struct t_allocator { void* memory; diff --git a/include/asset_defs.h b/include/asset_defs.h index 8249177..ff534fc 100644 --- a/include/asset_defs.h +++ b/include/asset_defs.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_ASSET_DEFS #define INCLUDE_ASSET_DEFS -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" /////// Loaded at game start. image* img_splash_art1; diff --git a/include/audio.h b/include/audio.h index db979df..63dcab0 100644 --- a/include/audio.h +++ b/include/audio.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_AUDIO_ #define INCLUDE_AUDIO_ -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #include "throwables.h" #define NUMBER_OF_AUDIO_CHANNELS 64 diff --git a/include/bullets.h b/include/bullets.h index 28ad175..253dc0a 100644 --- a/include/bullets.h +++ b/include/bullets.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_BULLETS #define INCLUDE_BULLETS -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #include "players.h" #include "objects.h" diff --git a/include/drops.h b/include/drops.h index 91ec03e..4e8158c 100644 --- a/include/drops.h +++ b/include/drops.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_DROPS #define INCLUDE_DROPS -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #include "guns.h" diff --git a/include/fog_of_war.h b/include/fog_of_war.h new file mode 100644 index 0000000..2e0efd2 --- /dev/null +++ b/include/fog_of_war.h @@ -0,0 +1,8 @@ +#ifndef INCLUDE_FOG_OF_WAR +#define INCLUDE_FOG_OF_WAR + +#include "../project-base/src/project_base.h" + +void draw_fog_of_war(platform_window* window); + +#endif diff --git a/include/game.h b/include/game.h index 91f471d..c70de8e 100644 --- a/include/game.h +++ b/include/game.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_GAME #define INCLUDE_GAME -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #include "../include/protocol.h" #include "../include/players.h" diff --git a/include/keybindings.h b/include/keybindings.h index fcdfda1..f41de4c 100644 --- a/include/keybindings.h +++ b/include/keybindings.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_KEYBINDINGS #define INCLUDE_KEYBINDINGS -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" typedef struct t_keybinding { int key; diff --git a/include/list.h b/include/list.h index db174c7..724045a 100644 --- a/include/list.h +++ b/include/list.h @@ -2,7 +2,7 @@ #ifndef INCLUDE_LIST #define INCLUDE_LIST -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #include "allocator.h" diff --git a/include/map.h b/include/map.h index 13983c0..c67eac3 100644 --- a/include/map.h +++ b/include/map.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_MAP #define INCLUDE_MAP -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #include "players.h" #include "objects.h" diff --git a/include/math_helper.h b/include/math_helper.h index bfbc1cd..4bec681 100644 --- a/include/math_helper.h +++ b/include/math_helper.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_MATH_HELPER #define INCLUDE_MATH_HELPER -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #include "players.h" #include "objects.h" diff --git a/include/menu.h b/include/menu.h index 9a448cd..bdd6012 100644 --- a/include/menu.h +++ b/include/menu.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_MENU #define INCLUDE_MENU -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #define PROGRAM_VERSION "0.1 | "__DATE__ diff --git a/include/objects.h b/include/objects.h index a8baf3c..5be7225 100644 --- a/include/objects.h +++ b/include/objects.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_OBJECT #define INCLUDE_OBJECT -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #include "map.h" diff --git a/include/overlay.h b/include/overlay.h index acbe1e4..b438c1c 100644 --- a/include/overlay.h +++ b/include/overlay.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_OVERLAY #define INCLUDE_OVERLAY -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" u64 logic_update_time = 0; diff --git a/include/pathfinding.h b/include/pathfinding.h index 4eace4c..33eb409 100644 --- a/include/pathfinding.h +++ b/include/pathfinding.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_PATHFINDING #define INCLUDE_PATHFINDING -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #include "allocator.h" #include "players.h" diff --git a/include/players.h b/include/players.h index 1343e14..c560678 100644 --- a/include/players.h +++ b/include/players.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_PLAYER #define INCLUDE_PLAYER -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #include "map.h" #include "objects.h" diff --git a/include/protocol.h b/include/protocol.h index 001e601..1a4b210 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_PROTOCOL #define INCLUDE_PROTOCOL -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #include "list.h" #include "players.h" diff --git a/include/rounds.h b/include/rounds.h index 4edbde2..dd2db94 100644 --- a/include/rounds.h +++ b/include/rounds.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_ROUNDS #define INCLUDE_ROUNDS -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #define ROUND_SWITCH_TIME 6.0f diff --git a/include/sprite.h b/include/sprite.h index 6c314d0..02045d0 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_SPRITE #define INCLUDE_SPRITE -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" typedef struct t_sprite { int current_frame; diff --git a/include/throwables.h b/include/throwables.h index c741a55..a24d7e2 100644 --- a/include/throwables.h +++ b/include/throwables.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_THROWABLES #define INCLUDE_THROWABLES -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #include "players.h" #include "objects.h" diff --git a/include/wall_item.h b/include/wall_item.h index 231788e..9bf0313 100644 --- a/include/wall_item.h +++ b/include/wall_item.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_WALL_ITEM #define INCLUDE_WALL_ITEM -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #include "objects.h" #include "guns.h" diff --git a/include/zombie_chunk.h b/include/zombie_chunk.h index 7beb14c..a5df279 100644 --- a/include/zombie_chunk.h +++ b/include/zombie_chunk.h @@ -1,7 +1,7 @@ #ifndef ZOMBIE_CHUNK #define ZOMBIE_CHUNK -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #include "objects.h" diff --git a/include/zombies.h b/include/zombies.h index a0cbc79..3dd01cc 100644 --- a/include/zombies.h +++ b/include/zombies.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_ZOMBIES #define INCLUDE_ZOMBIES -#include <projectbase/project_base.h> +#include "../project-base/src/project_base.h" #include "players.h" #include "objects.h" diff --git a/libs/msvc/SDL2.dll b/libs/msvc/SDL2.dll Binary files differnew file mode 100644 index 0000000..431ca7e --- /dev/null +++ b/libs/msvc/SDL2.dll @@ -42,6 +42,7 @@ #include "include/editor.h" #include "include/glass_doors.h" #include "include/menu.h" +#include "include/fog_of_war.h" #include "src/map.c" #include "src/players.c" @@ -67,6 +68,7 @@ #include "src/editor.c" #include "src/glass_doors.c" #include "src/menu.c" +#include "src/fog_of_war.c" #define CONFIG_DIRECTORY "zombieshooter" @@ -1,4 +1,4 @@ -call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 +call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 @set OUT_DIR=build\\ @set OUT_EXE=zombies @set SOURCES=main.c diff --git a/src/fog_of_war.c b/src/fog_of_war.c new file mode 100644 index 0000000..3b1a0c0 --- /dev/null +++ b/src/fog_of_war.c @@ -0,0 +1,56 @@ +#include "../include/fog_of_war.h" + +void draw_fog_of_war(platform_window* window) +{ + map_info info = get_map_info(window); + + int tilemap_render_min_y = (_global_camera.y / info.tile_height); + int tilemap_render_max_y = tilemap_render_min_y + (window->height/ info.tile_height) + 1; + + int tilemap_render_min_x = (_global_camera.x / info.tile_width); + int tilemap_render_max_x = tilemap_render_min_x + (window->width/ info.tile_width) + 1; + + static float dance_floor_disco_timestamp = 0.0f; + dance_floor_disco_timestamp += update_delta; + + for (int y = 0; y < MAP_SIZE_Y; y++) { + + if (y < tilemap_render_min_y) continue; + if (y > tilemap_render_max_y) continue; + + for (int x = 0; x < MAP_SIZE_X; x++) { + + if (x < tilemap_render_min_x) continue; + if (x > tilemap_render_max_x) continue; + + tile tile = loaded_map->heightmap[y][x]; + + float xdiff_between_bottom_and_top = info.px_incline; + float render_x = (info.tile_width * x) + (xdiff_between_bottom_and_top * y); + float render_y = info.tile_height * y; + render_y -= tile.height*info.px_raised_per_h; + + float brightness = 1.0f; + + for (int i = 0; i < MAX_PLAYERS; i++) { + if (!players[i].active) continue; + + float dist = distance_between((vec2f){.x = players[i].playerx, .y = players[i].playery}, + (vec2f){.x = x, .y = y}); + if (dist < 40.0f) { + float new_brightness = 1.0f / (40.0f - dist); + if (new_brightness < brightness) brightness = new_brightness; + break; + } + + bullet b1 = {.active = true, .position = {.x = players[i].playerx, .y = players[i].playery, .z = 0.0f}, .endx = x, .endy = y}; + object_type obj_collision = check_if_bullet_collided_with_object(&b1, window); + if (obj_collision != OBJECT_NONE) { + brightness = 1.0f; + } + } + + renderer->render_rectangle(render_x, render_y, info.tile_width, info.tile_height, rgba(0,0,0, (brightness*220.0f))); + } + } +}
\ No newline at end of file @@ -584,6 +584,7 @@ void update_game(platform_window* window) { draw_throwables(window); draw_round(window); draw_spawners(window); + //draw_fog_of_war(window); draw_overlay(window); #ifdef MODE_DEBUG |
