From 29d124b93125d7c9de762c45876f69df3acd549d Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Wed, 18 Oct 2017 19:53:51 +0200 Subject: Render bounds are now working. Start working on unit movement. --- src/world.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/world.cpp') 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; -- cgit