diff options
| author | Aldrik Ramaekers <aldrik@amftech.nl> | 2023-12-28 09:12:29 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik@amftech.nl> | 2023-12-28 09:12:29 +0100 |
| commit | 007335a39baff05fb7cabb07457cd5972a013fda (patch) | |
| tree | 8f43623138789a261fa814213b63a4723a650835 | |
| parent | c6e7e4b1b1b72e0b67a64332033e3f41f2407f09 (diff) | |
sort objects by yaxis
| -rw-r--r-- | build/zombies.exe | bin | 2110879 -> 2110845 bytes | |||
| -rw-r--r-- | src/map.c | 4 | ||||
| -rw-r--r-- | src/objects.c | 10 |
3 files changed, 7 insertions, 7 deletions
diff --git a/build/zombies.exe b/build/zombies.exe Binary files differindex 588716c..324f8e8 100644 --- a/build/zombies.exe +++ b/build/zombies.exe @@ -121,6 +121,10 @@ static bool ray_intersects_with_ground(vec3f begin, vec3f end) { return false; } +int sort_objects(const void * obj1, const void* obj2) { + return (((object*)obj1)->position.y - ((object*)obj2)->position.y); +} + void load_mapdata_into_world() { loaded_map.width = map_to_load.width; loaded_map.height = map_to_load.height; diff --git a/src/objects.c b/src/objects.c index 38670cc..ce1d261 100644 --- a/src/objects.c +++ b/src/objects.c @@ -56,10 +56,6 @@ object get_object_at_tile(float x, float y) { return (object){0}; } -int sort_objects(const void * obj1, const void* obj2) { - return (((object*)obj1)->position.y - ((object*)obj2)->position.y); -} - void add_object(object obj) { object existing_obj = get_object_at_tile(obj.position.x, obj.position.y); if (existing_obj.active) { @@ -72,12 +68,12 @@ void add_object(object obj) { if (o.active) continue; map_to_load.objects[i] = obj; map_to_load.objects[i].active = true; + + // sort y-axis + qsort(map_to_load.objects, MAX_OBJECTS, sizeof(object), sort_objects); return; } - // sort y-axis - qsort(map_to_load.objects, MAX_OBJECTS, sizeof(object), sort_objects); - log_info("Object limit reached."); } |
