summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-04-07 20:44:42 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-04-07 20:44:49 +0200
commit21eaaee936a47742f59eb6b5665422de2bd8e7ae (patch)
treeaeb89f45aaee920eeb88dd14ce53b76eb818d047 /src
parent82ec1a07c79b1c96688464609d043d6ce23685b1 (diff)
fix closed doors clipping through walls
Diffstat (limited to 'src')
-rw-r--r--src/character.cpp6
-rw-r--r--src/scenery.cpp19
2 files changed, 19 insertions, 6 deletions
diff --git a/src/character.cpp b/src/character.cpp
index 7934d1b3..5e42d4e8 100644
--- a/src/character.cpp
+++ b/src/character.cpp
@@ -3,6 +3,7 @@
#include "loader/loader.hpp"
#include "src/world.hpp"
#include "src/entity.hpp"
+#include "shaders/tile.hpp"
#include "src/RTree-search.hpp"
#include <cmath>
#include <utility>
@@ -128,7 +129,10 @@ void character::set_keys(bool L, bool R, bool U, bool D)
b_D = D;
}
-Vector2 character::depth_offset() const { return {}; }
+Vector2 character::depth_offset() const
+{
+ return Vector2(tile_shader::character_depth_offset, 0);
+}
Vector2 character::ordinal_offset(Vector2b offset) const
{
diff --git a/src/scenery.cpp b/src/scenery.cpp
index ff78bfa8..873dcf93 100644
--- a/src/scenery.cpp
+++ b/src/scenery.cpp
@@ -3,6 +3,7 @@
#include "chunk.hpp"
#include "compat/assert.hpp"
#include "world.hpp"
+#include "shaders/tile.hpp"
#include "src/rotation.inl"
#include <algorithm>
@@ -89,16 +90,24 @@ Vector2 scenery::ordinal_offset(Vector2b offset) const
Vector2 scenery::depth_offset() const
{
+ constexpr auto sc_offset = tile_shader::scenery_depth_offset;
constexpr auto inv_tile_size = 1.f/TILE_SIZE2;
Vector2 ret;
+ ret += Vector2(atlas->group(r).depth_offset) * inv_tile_size;
if (sc_type == scenery_type::door)
{
- constexpr auto door_offset = Vector2b(-bTILE_SIZE[0], 0);
- const auto offset = rotate_point(door_offset, rotation::N, r);
- ret += Vector2(offset);
+ const bool is_open = frame != atlas->info().nframes-1;
+ ret += Vector2(is_open ? sc_offset : -sc_offset, 0);
+ constexpr auto off_opened = Vector2(-1, 0);
+ constexpr auto off_closed = Vector2(0, 0);
+ const auto vec = is_open ? off_opened : off_closed;
+ const auto offset = rotate_point(vec, rotation::N, r);
+ ret += offset;
}
- ret += Vector2(atlas->group(r).depth_offset);
- return ret * inv_tile_size;
+ else
+ ret += Vector2(sc_offset, 0);
+
+ return ret;
}
bool scenery::activate(size_t)