summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrikboy@gmail.com>2024-05-16 10:10:10 +0200
committerAldrik Ramaekers <aldrikboy@gmail.com>2024-05-16 10:10:10 +0200
commitfa7b6b01b68ad3934734e67b65d31d0d4ccfa0a6 (patch)
treed6cc530489e0dbe677f6916685f65ab208cd2356
parent197958d8e7f539de6b1da937fddbbbfcf167a73b (diff)
temp
-rw-r--r--include/objects.h5
-rw-r--r--src/map.c10
-rw-r--r--src/objects.c26
3 files changed, 38 insertions, 3 deletions
diff --git a/include/objects.h b/include/objects.h
index 36ae30f..4850a90 100644
--- a/include/objects.h
+++ b/include/objects.h
@@ -6,6 +6,7 @@
#include "map.h"
#define MAX_OBJECTS 10000
+#define MAX_DECORATION_OBJECTS 100
typedef struct t_vec3f {
float x,y,z;
@@ -130,6 +131,10 @@ object object_dict[OBJECT_END] = {
{0,(vec3f){0, 0, 0},{1,2,1},OBJECT_GLASS_DOOR_V, 0},
};
+// decoration objects laying on floor.
+object decoration_objects[MAX_DECORATION_OBJECTS] = {0};
+
+void add_decoration_object(object o);
object get_object_at_tile(float x, float y);
object* get_pobject_at_tile(float x, float y);
object* get_object_at_tile_from_mapfile(float x, float y);
diff --git a/src/map.c b/src/map.c
index 5beb136..9e0e7cd 100644
--- a/src/map.c
+++ b/src/map.c
@@ -275,11 +275,19 @@ void load_mapdata_into_world() {
if (o.type == OBJECT_ZOMBIE_SPAWNER) {
create_spawner((vec2){.x = o.position.x, .y = o.position.y});
+ loaded_map.objects[i].active = 0;
}
if (o.type == OBJECT_GLASS_DOOR_H || o.type == OBJECT_GLASS_DOOR_V) {
create_glass_door(o);
- }
+ loaded_map.objects[i].active = 0;
+ }
+
+ if (o.type == OBJECT_BOWLING_LANE)
+ {
+ add_decoration_object(o);
+ loaded_map.objects[i].active = 0;
+ }
}
}
diff --git a/src/objects.c b/src/objects.c
index 371040b..9342eb0 100644
--- a/src/objects.c
+++ b/src/objects.c
@@ -174,16 +174,38 @@ image* get_image_from_objecttype(object_type tile) {
}
}
+void add_decoration_object(object o)
+{
+ for (int i = 0; i < MAX_DECORATION_OBJECTS; i++)
+ {
+ if (decoration_objects[i].active) continue;
+ decoration_objects[i] = o;
+ }
+}
+
void draw_objects(platform_window* window) {
map_info info = get_map_info(window);
+ // Draw decoration objects laying on floor first.
+ for (int i = 0; i < MAX_DECORATION_OBJECTS; i++) {
+ if (!decoration_objects[i].active) continue;
+ object o = decoration_objects[i];
+ box box = get_box_of_object(window, o);
+ image* img = get_image_from_objecttype(o.type);
+ if (img) {
+ renderer->render_image(img, box.tl_u.x, box.tl_u.y,
+ box.br_d.x - box.tl_d.x, box.br_d.y - box.tr_u.y);
+ }
+ }
+
float prev_y = 0;
for (int i = 0; i < MAX_OBJECTS; i++) {
if (!loaded_map.objects[i].active) continue;
object o = loaded_map.objects[i];
- if (o.type == OBJECT_GLASS_DOOR_H) continue;
- if (o.type == OBJECT_GLASS_DOOR_V) continue;
+ //if (o.type == OBJECT_GLASS_DOOR_H) continue;
+ //if (o.type == OBJECT_GLASS_DOOR_V) continue;
+ //if (o.type == OBJECT_BOWLING_LANE) continue;
box box = get_box_of_object(window, o);