예제 #1
0
CollisionDirection CollisionHandler::DetectCollisionWithObj(MovingObject& _obj, DisplayableObject& _ref)
{
	if (_obj.GetID() == _ref.GetID())
		return NO_COL;

	return DetectCollisionWithRect(_obj.GetCoordinates(), _ref.GetCoordinates());
}
예제 #2
0
void GameEngine::UpdateCharacterPosition(MovingObject& _character, float _dt)
{
	unsigned int id = _character.GetID();

	_character.UpdatePosition(_dt);

	sf::Vector2f pos = _character.GetPosition();
	m_listForegroundItems[id]->SetX(pos.x);
	m_listForegroundItems[id]->SetY(pos.y);
}
예제 #3
0
void CollisionHandler::ReactToCollisionsWithObj(MovingObject& _obj, DisplayableObject& _ref, CollisionDirection _direction)
{
	ReactToCollision(_obj, _ref.GetCoordinates(), _direction);

	_obj.UpdateAfterCollision(Util::OppositeCollisionDirection(_direction), _ref.GetClass()); // Updates the state of the object, not its coordinates
	_obj.SetPosition(m_gameEngine->GetCoordinatesOfForegroundItem(_obj.GetID()));

	_ref.UpdateAfterCollision(_direction, _obj.GetClass());

	SendNewObjectPositionToGFX(_ref);
}