Esempio n. 1
0
void GameObject::recalcExtens()
{
	assert(m_size.x >= 0.0f);
	assert(m_size.y >= 0.0f);
	m_topLeft.x		= m_offset.x + m_position.x - (getSizeInTiles().x*0.5f);
	m_topLeft.y		= m_offset.y + m_position.y - (getSizeInTiles().y*0.5f);
	m_bottomRight.x	= m_offset.x + m_position.x + (getSizeInTiles().x*0.5f);
	m_bottomRight.y	= m_offset.y + m_position.y + (getSizeInTiles().y*0.5f);
}
Esempio n. 2
0
bool GameObject::collidesTo( GameObject* other, vec2* collisionNormalLikeVector )
{
	assert( other != 0 );

	vec2 d1 = other->m_topLeft - m_bottomRight;
	vec2 d2 = m_topLeft - other->m_bottomRight;

	if( d1.x > 0.0f || d1.y > 0.0f || d2.x > 0.0f || d2.y > 0.0f )
	{
		return false;
	}

	if (collisionNormalLikeVector != 0)
	{
		vec2 sthis = getSizeInTiles();
		vec2 so = other->getSizeInTiles();
		vec2 d = d2 - d1;
		d.x /= sthis.x + so.x;
		d.y /= sthis.y + so.y;
		
		*collisionNormalLikeVector = d;
	}

	return true;
}
Esempio n. 3
0
    BoundingBox World::getBoundingBox() const {
        const Int2 tileSize = getSizeInTiles();

        return BoundingBox(
            GLFloatVec2(0.0f, 0.0f),
            GLFloatVec2(static_cast< GLfloat >(tileSize.x), static_cast< GLfloat >(tileSize.y))
        );
    }