Ejemplo n.º 1
0
void Game::hitRacket(const Player* pPlayer, const Racket* pRacket, HitRecord& lhr, HitRecord& hr, bool& hit)
{
	if (Calculator::hit(*m_pBall, *pRacket, *m_pField, lhr) == true)
	{
		hit = true;
		hr = lhr;
		float x = (hr.getHitPoint().getX() - pRacket->getPosition().getX()) / Racket::WIDTH;
		if (x > 0.5f) x = 0.5f;
		if (x < -0.5f) x = -0.5f;
		math::Normal2<float> norm = hr.getNormal();
		const float coef = 1.0f;
		norm.setX(norm.getX() + (x * coef));
		norm.normalize();
		hr.setNormal(norm);
		setBallOwner(pPlayer);
	}
}
Ejemplo n.º 2
0
void Game::setBallPosition(const HitRecord& hr)
{
	m_pBall->position() = hr.getNewPosition();
	Calculator::bounce(*m_pBall, hr.getNormal());
	Calculator::move(*m_pBall, hr.getRollback() + 0.1f);
}