Refactored sprite & transform. Replaced distance with collider when picking objects up.
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user