summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-04-12 18:58:52 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-04-12 19:08:03 +0200
commit38efeacfd21be1c44d51b18fe9a11b0624a77cda (patch)
treead6b8632d302836e968db0115a3357694c948d5c /src
parentee38547c4f22ed48572a605ca71f26bd374a90ba (diff)
aaaa
Diffstat (limited to 'src')
-rw-r--r--src/camera-offset.cpp43
-rw-r--r--src/character.cpp2
2 files changed, 21 insertions, 24 deletions
diff --git a/src/camera-offset.cpp b/src/camera-offset.cpp
index de6f584d..ab547387 100644
--- a/src/camera-offset.cpp
+++ b/src/camera-offset.cpp
@@ -12,29 +12,26 @@ with_shifted_camera_offset::with_shifted_camera_offset(tile_shader& shader, chun
constexpr auto chunk_size = TILE_MAX_DIM20d*dTILE_SIZE;
auto offset = _camera + tile_shader::project(Vector3d(c_.x, c_.y, 0) * chunk_size);
- auto pos = Vector2d(chunk_coords(c_) - first_);
- auto len = Vector2d(last_ - first_) + Vector2d(1, 1);
- auto pos1 = pos.y() * len.x() + pos.x();
- auto z = c_.z - chunk_z_min;
- constexpr auto depth_start = -1 + 1.111e-16;
-
- double chunk_offset, tile_offset;
-
- if (c_.z < chunk_z_max)
- {
- chunk_offset = depth_start + tile_shader::depth_chunk_size * pos1;
- tile_offset = (double)tile_shader::depth_value({z, z});
- }
- else
- {
- chunk_offset = 1;
- tile_offset = 0;
- }
-
- double depth_offset_ = chunk_offset + tile_offset;
- auto depth_offset = (float)depth_offset_;
-
- _shader.set_camera_offset(offset, depth_offset);
+ auto z = (int)(c_.z - chunk_z_min);
+ auto pos = chunk_coords(c_) - first_;
+ auto len = (last_ - first_) + Vector2i(1, 1);
+ constexpr auto depth_start = -1 + 1.111e-16f;
+
+ int depth = TILE_MAX_DIM * pos.x() +
+ (int)TILE_COUNT * len.x() * pos.y() +
+ z * (TILE_MAX_DIM+1);
+
+#if 1
+ if (c_.z == 0)
+ printf("c=(%2hd %2hd %2hhd) pos=(%2d %2d) len=(%d %d) --> %d\n", c_.x, c_.y, c_.z, pos.x(), pos.y(), len.x(), len.y(), depth);
+#endif
+
+ float d = depth * tile_shader::depth_tile_size + depth_start;
+
+ if (c_.z == chunk_z_max)
+ d = 1;
+
+ _shader.set_camera_offset(offset, d);
}
with_shifted_camera_offset::~with_shifted_camera_offset()
diff --git a/src/character.cpp b/src/character.cpp
index a2098788..88b55d45 100644
--- a/src/character.cpp
+++ b/src/character.cpp
@@ -17,7 +17,7 @@ namespace {
template <typename T> constexpr T sgn(T val) { return T(T(0) < val) - T(val < T(0)); }
constexpr int tile_size_1 = iTILE_SIZE2.sum()/2,
- framerate = 96, move_speed = tile_size_1 * 2;
+ framerate = 96 * 3, move_speed = tile_size_1 * 2 * 3;
constexpr float frame_time = 1.f/framerate;
constexpr auto arrows_to_dir(bool left, bool right, bool up, bool down)