Refactored sprite & transform. Replaced distance with collider when picking objects up.

This commit is contained in:
2016-12-15 22:52:36 +02:00
parent ddae4934ef
commit 42f0d4125b
20 changed files with 273 additions and 208 deletions

View File

@ -60,17 +60,14 @@ void Grid::onInitialize()
GameObject* obj = *it;
// Compute grid position(s)
Rect<int> bounds(obj->transform.x, obj->transform.y, roundf(obj->transform.w), roundf(obj->transform.h));
if (!bounds.intersects(m_bounds))
if (!m_bounds.contains(obj->transform.x, obj->transform.y))
{
std::cerr << "Grid: ignoring object " << obj->name << ": object outside allowed bounds.";
continue;
}
// Set
for (int y = bounds.y; y < bounds.y + bounds.h; y++)
for (int x = bounds.x; x < bounds.x + bounds.w; x++)
set(obj, x, y, false);
set(obj, (int)obj->transform.x, (int)obj->transform.y, false);
}
}