summaryrefslogtreecommitdiff
path: root/src/world.cpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-10-18 19:53:51 +0200
committerPaweł Redman <pawel.redman@gmail.com>2017-10-18 19:53:51 +0200
commit29d124b93125d7c9de762c45876f69df3acd549d (patch)
treed940787ca232a9d0587dc83856f054b9aa401e23 /src/world.cpp
parentef5273d2c2ab801b11eb435a04bff96f6e778b1c (diff)
Render bounds are now working. Start working on unit movement.
Diffstat (limited to 'src/world.cpp')
-rw-r--r--src/world.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/world.cpp b/src/world.cpp
index 511de12..d2fc2bb 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -160,24 +160,20 @@ void entity_t::link_to_sector(sector_t *sector)
void entity_t::link(world_t *world)
{
- //sf::FloatRect total_bounds;
+ rectf_t total_bounds;
float fx, fy;
sector_index_t base;
float xlip, ylip;
size_t xsecs, ysecs;
- // TODO
- //total.bounds.left = std::min(bounds.left, render_bounds.left);
- //total.bounds.top = std::min(bounds.top, render_bounds.top);
- //total.bounds.width = std::max(bounds.width, render_bounds.width);
- //total.bounds.height = std::max(bounds.height, render_bounds.height);
+ total_bounds = bounds + render_bounds;
- fx = floor(bounds[0][0]);
- fy = floor(bounds[0][1]);
+ fx = floor(total_bounds[0][0]);
+ fy = floor(total_bounds[0][1]);
base = sector_index_at(v2f_t(fx, fy));
- xlip = bounds[1][0] - (base[0] + 1) * SECTOR_SIZE;
- ylip = bounds[1][1] - (base[1] + 1) * SECTOR_SIZE;
+ xlip = total_bounds[1][0] - (base[0] + 1) * SECTOR_SIZE;
+ ylip = total_bounds[1][1] - (base[1] + 1) * SECTOR_SIZE;
if (xlip > 0.0f)
xsecs = ceil(xlip / SECTOR_SIZE) + 1;