feat(player): hit-box 8×8 per a contacte actor-actor (player, momia, trampa)
This commit is contained in:
1 parent
511f8d5b09
commit
858e444842
6 files changed
+84
-8
No files matched your search
@@ -65,7 +65,11 @@ void EntityManager::checkPlayerCollisions(const std::vector<Player*>& players) {
|
||||
const auto BOX = entity->getCollisionRect();
|
||||
for (auto* p : players) {
|
||||
if (p == nullptr) { continue; }
|
||||
const auto PBOX = p->getBaseBox();
|
||||
// Contacte actor-actor amb hit-box petita: la caixa base
|
||||
// 16×16 servia per moure (xoc amb murs), però per a l'event
|
||||
// "toca una entitat" volem precisió — que la momia mate quan
|
||||
// els píxels centrals es solapen, no quan els caps es freguen.
|
||||
const auto PBOX = p->getHitBox();
|
||||
const bool OVERLAP = PBOX.x + PBOX.w > BOX.x && BOX.x + BOX.w > PBOX.x && PBOX.y + PBOX.h > BOX.y && BOX.y + BOX.h > PBOX.y;
|
||||
if (OVERLAP) { entity->onPlayerContact(p); }
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user