summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.zipbin0 -> 1184740 bytes
-rw-r--r--build/data/imgs/nova.pngbin0 -> 3670 bytes
-rw-r--r--build/zombies.exebin1738175 -> 1740455 bytes
-rw-r--r--data/imgs/nova.pngbin0 -> 3670 bytes
-rw-r--r--include/asset_defs.h2
-rw-r--r--include/guns.h1
-rw-r--r--include/wall_item.h33
-rw-r--r--main.c2
-rw-r--r--project-base.code-workspace3
-rw-r--r--src/asset_defs.c2
-rw-r--r--src/drops.c1
-rw-r--r--src/game.c2
-rw-r--r--src/guns.c13
-rw-r--r--src/objects.c3
-rw-r--r--src/pathfinding.c2
-rw-r--r--src/players.c4
-rw-r--r--src/wall_item.c49
17 files changed, 112 insertions, 5 deletions
diff --git a/build.zip b/build.zip
new file mode 100644
index 0000000..e7080d9
--- /dev/null
+++ b/build.zip
Binary files differ
diff --git a/build/data/imgs/nova.png b/build/data/imgs/nova.png
new file mode 100644
index 0000000..00f62df
--- /dev/null
+++ b/build/data/imgs/nova.png
Binary files differ
diff --git a/build/zombies.exe b/build/zombies.exe
index 1922106..ff79bbf 100644
--- a/build/zombies.exe
+++ b/build/zombies.exe
Binary files differ
diff --git a/data/imgs/nova.png b/data/imgs/nova.png
new file mode 100644
index 0000000..00f62df
--- /dev/null
+++ b/data/imgs/nova.png
Binary files differ
diff --git a/include/asset_defs.h b/include/asset_defs.h
index ee520ea..480f97f 100644
--- a/include/asset_defs.h
+++ b/include/asset_defs.h
@@ -8,6 +8,8 @@ font* fnt_20;
image* img_icon_bullets;
+image* img_icon_nova;
+
void load_assets();
#endif \ No newline at end of file
diff --git a/include/guns.h b/include/guns.h
index 0363cae..1b93781 100644
--- a/include/guns.h
+++ b/include/guns.h
@@ -25,6 +25,7 @@ gun guns[GUN_ALL] = {
{GUN_NOVA, "Nova", 12, 80, 0.2f, 3, 1.2f},
};
+image* get_image_of_gun(gun_type type);
gun get_gun_by_type(gun_type type);
#endif \ No newline at end of file
diff --git a/include/wall_item.h b/include/wall_item.h
new file mode 100644
index 0000000..2e6bdd3
--- /dev/null
+++ b/include/wall_item.h
@@ -0,0 +1,33 @@
+#ifndef INCLUDE_WALL_ITEM
+#define INCLUDE_WALL_ITEM
+
+#include <projectbase/project_base.h>
+
+#include "guns.h"
+
+typedef enum t_wall_item_type {
+ WALLITEM_GUN,
+} wall_item_type;
+
+typedef union t_wall_item_data {
+ gun_type gun;
+} wall_item_data;
+
+typedef struct t_wall_item {
+ bool active;
+ vec3f position;
+ float time_active;
+ float start_h;
+ wall_item_type item;
+ wall_item_data data;
+ image* img;
+} wall_item;
+
+#define MAX_WALLITEMS (20)
+wall_item wallitems[MAX_WALLITEMS] = {0};
+
+void update_wallitems();
+void draw_wallitems(platform_window* window);
+void create_wallitem(vec3f position, wall_item_type item, wall_item_data data);
+
+#endif \ No newline at end of file
diff --git a/main.c b/main.c
index dccdb5d..6d397cd 100644
--- a/main.c
+++ b/main.c
@@ -15,6 +15,7 @@
#include "include/overlay.h"
#include "include/asset_defs.h"
#include "include/drops.h"
+#include "include/wall_item.h"
#include "src/map.c"
#include "src/players.c"
@@ -31,6 +32,7 @@
#include "src/overlay.c"
#include "src/asset_defs.c"
#include "src/drops.c"
+#include "src/wall_item.c"
#define CONFIG_DIRECTORY "zombieshooter"
diff --git a/project-base.code-workspace b/project-base.code-workspace
index 095bb87..2045268 100644
--- a/project-base.code-workspace
+++ b/project-base.code-workspace
@@ -65,7 +65,8 @@
"game.h": "c",
"bullets.h": "c",
"guns.h": "c",
- "iphlpapi.h": "c"
+ "iphlpapi.h": "c",
+ "asset_defs.h": "c"
}
}
} \ No newline at end of file
diff --git a/src/asset_defs.c b/src/asset_defs.c
index a51dfe8..d122b6b 100644
--- a/src/asset_defs.c
+++ b/src/asset_defs.c
@@ -5,4 +5,6 @@ void load_assets() {
fnt_20 = assets_load_font(mono_ttf, mono_ttf+mono_ttf_len, 20);
img_icon_bullets = assets_load_image_from_file("data/imgs/bullets.png");
+
+ img_icon_nova = assets_load_image_from_file("data/imgs/nova.png");
} \ No newline at end of file
diff --git a/src/drops.c b/src/drops.c
index a03f7ca..e5e1d7b 100644
--- a/src/drops.c
+++ b/src/drops.c
@@ -15,7 +15,6 @@ void handle_drop_pickup(player* p, drop* d) {
void update_drops() {
#define MAX_HEIGHT_DIFF (0.3f)
- #define FREQUENCY (0.15)
for (int i = 0; i < MAX_DROPS; i++) {
drop b = drops[i];
diff --git a/src/game.c b/src/game.c
index 7bef631..893d482 100644
--- a/src/game.c
+++ b/src/game.c
@@ -155,6 +155,7 @@ void update_server(platform_window* window) {
update_spawners();
update_drops();
+ update_wallitems();
update_bullets(window);
update_players_server();
update_zombies_server(window);
@@ -256,6 +257,7 @@ void update_game(platform_window* window) {
take_player_input(window);
draw_grid(window);
+ draw_wallitems(window);
draw_drops(window);
draw_bullets(window);
draw_zombies(window);
diff --git a/src/guns.c b/src/guns.c
index 62f4690..8741fa6 100644
--- a/src/guns.c
+++ b/src/guns.c
@@ -1,5 +1,18 @@
#include "../include/guns.h"
+#include "../include/asset_defs.h"
gun get_gun_by_type(gun_type type) {
return guns[type];
+}
+
+image* get_image_of_gun(gun_type type) {
+ switch (type)
+ {
+ case GUN_NOVA: return img_icon_nova; break;
+
+ default:
+ break;
+ }
+
+ return 0;
} \ No newline at end of file
diff --git a/src/objects.c b/src/objects.c
index 23a57c6..a4d86e1 100644
--- a/src/objects.c
+++ b/src/objects.c
@@ -1,4 +1,5 @@
#include "../include/objects.h"
+#include "../include/wall_item.h"
box get_box_of_object(platform_window* window, object o) {
return get_render_box_of_square(window, (vec3f){o.position.x, o.position.y, o.h}, o.size);
@@ -79,4 +80,6 @@ void create_objects() {
create_box(14, 10, 0);
create_box(13, 10, 0);
create_box(11, 10, 0);
+
+ create_wallitem((vec3f){14, 1, 0}, WALLITEM_GUN, (wall_item_data){.gun = GUN_NOVA});
} \ No newline at end of file
diff --git a/src/pathfinding.c b/src/pathfinding.c
index effca06..88bcd23 100644
--- a/src/pathfinding.c
+++ b/src/pathfinding.c
@@ -87,7 +87,7 @@ bool find_path_to(vec2f start_pos, vec2f end_pos, array *to_fill, pathfinding_re
}
if (to_fill) {
- array_remove_at(to_fill, to_fill->length-1);
+ if (to_fill->length > 1) array_remove_at(to_fill, to_fill->length-1);
//printf("PATHFINDING TOOK: %fms\n", (platform_get_time(TIME_PROCESS, TIME_MS)-timestamp)/1000.0f);
}
mutex_unlock(&request->mutex);
diff --git a/src/players.c b/src/players.c
index 5509067..7244cc4 100644
--- a/src/players.c
+++ b/src/players.c
@@ -180,8 +180,8 @@ void take_player_input(platform_window* window) {
dirx /= length;
diry /= length;
- float gun_offset_x = (get_player_size_in_tile()/2) + dirx/2;
- float gun_offset_y = (get_player_size_in_tile()/2) + diry/2;
+ float gun_offset_x = (get_player_size_in_tile()/2) + dirx;
+ float gun_offset_y = (get_player_size_in_tile()/2) + diry;
p->gunx = p->playerx + gun_offset_x;
p->guny = p->playery + gun_offset_y;
diff --git a/src/wall_item.c b/src/wall_item.c
new file mode 100644
index 0000000..a9f556c
--- /dev/null
+++ b/src/wall_item.c
@@ -0,0 +1,49 @@
+#include "../include/wall_item.h"
+
+static image* get_wallitem_img(wall_item_type item, wall_item_data data) {
+ switch(item) {
+ case WALLITEM_GUN: return get_image_of_gun(data.gun);
+ }
+
+ return 0;
+}
+
+void create_wallitem(vec3f position, wall_item_type type, wall_item_data data) {
+ wall_item item;
+ item.active = true;
+ item.position = position;
+ item.item = type;
+ item.data = data;
+ item.start_h = position.z;
+ item.time_active = 0.0f;
+ item.img = get_wallitem_img(type, data);
+
+ for (int i = 0; i < MAX_WALLITEMS; i++) {
+ wall_item ei = wallitems[i];
+ if (ei.active) continue;
+ wallitems[i] = item;
+ return;
+ }
+}
+
+void update_wallitems() {
+ #define MAX_HEIGHT_DIFF_FOR_WALLITEM (0.1f)
+
+ for (int i = 0; i < MAX_WALLITEMS; i++) {
+ wall_item item = wallitems[i];
+ if (!item.active) continue;
+
+ wallitems[i].time_active += update_delta;
+ wallitems[i].position.z = MAX_HEIGHT_DIFF_FOR_WALLITEM * sin (2 * M_PI * 0.5f * (wallitems[i].time_active) + 0) + item.start_h;
+ }
+}
+
+void draw_wallitems(platform_window* window) {
+ for (int i = 0; i < MAX_WALLITEMS; i++) {
+ wall_item item = wallitems[i];
+ if (!item.active) continue;
+
+ box box = get_render_box_of_square(window, item.position, (vec3f){1,1,2});
+ renderer->render_image(item.img, box.tl_u.x, box.tl_u.y, box.tr_u.x - box.tl_u.x, box.br_u.y - box.tr_u.y);
+ }
+} \ No newline at end of file