void Player::checkLoot() { // Calculate loot area Rect lootArea = getRect(); if(getWeapon() != NULL) { // Add weapons width to loot area :NOTE: :TODO: Gives wrong result when the weapon is centered on the player etc... if(mFaceDirection == RIGHT) lootArea.right += getWeapon()->getWidth(); else if(mFaceDirection == LEFT) lootArea.left -= getWeapon()->getWidth(); } // Add some extra area lootArea.bottom += 20; lootArea.top -= 20; lootArea.left -= 20; lootArea.right += 20; // Find loot inside loot area Object* lootObject = getLevel()->findCollision(lootArea, getId(), LOOT); // If an object is found if(lootObject != NULL) { // If the object is loot if(lootObject->getType() == LOOT) { // Cast and call equip() Loot* loot = dynamic_cast<Loot*>(lootObject); loot->equip(this); } } }