Exemplo n.º 1
0
void TEALShow::AddTransformedRectanglePoints( sf::FloatRect r, sf::Transform T, sf::Color col )
{
	Linestrip strip;
	strip.size = 5;
	strip.points.resize(strip.size); 
	strip.points[0].position = T.transformPoint( sf::Vector2f( r.left, r.top) );
	strip.points[0].color = col;
	strip.points[1].position = T.transformPoint( sf::Vector2f(r.left + r.width,  r.top ) );
	strip.points[1].color = col;
	strip.points[2].position = T.transformPoint( sf::Vector2f( r.left + r.width, r.top + r.height ));
	strip.points[2].color = col;
	strip.points[3].position = T.transformPoint( sf::Vector2f( r.left, r.top + r.height ) );
	strip.points[3].color = col;
	strip.points[4] = strip.points[0];

	LinestripList.push_back( strip);
}
Exemplo n.º 2
0
void Fruit::Draw(sf::RenderTarget& target, sf::Transform const& transform)
{
    if (m_Visible)
    {
        sf::Vector2f const pos = transform.transformPoint(m_Position);
        m_Sprite.SetPosition(pos);
        m_Sprite.Draw(target);
    }
}
Exemplo n.º 3
0
	sf::View Camera::getView(const sf::Transform& transform) const
	{
		if (mEntityManager.hasEntity(mSubjectID))
		{
			BaseGameEntity& subject = mEntityManager.getEntityFromID(mSubjectID);
			sf::View view(transform.transformPoint(subject.getWorldTransform().transformPoint(0, 0)), mSize);
			return view;
		}
		else
		{
			return sf::View();
		}
	}
Exemplo n.º 4
0
void CircleMask::updateTransform(const sf::Transform& transform)
{
	const sf::Vector2f x1(transform.transformPoint(-1.f, 0.f));
	const sf::Vector2f x2(transform.transformPoint(1.f, 0.f));
	const sf::Vector2f y1(transform.transformPoint(0.f, -1.f));
	const sf::Vector2f y2(transform.transformPoint(0.f, 1.f));

	const float scaleX = je::length(x2 - x1);
	const float scaleY = je::length(y2 - y1);

	// until we decide to handle elipses
	const float epsilon = 0.1f;
	JE_ASSERT(scaleX >= scaleY - epsilon && scaleX <= scaleY + epsilon);

	radius = originalRadius * scaleX * baseTransform.getScale().x;
	center = baseTransform.getTransform().transformPoint((x2 + x1) * 0.5f);

#ifdef JE_DEBUG
	debugCircle.setRadius(radius);
	debugCircle.setOrigin(radius, radius);
	debugCircle.setPosition(center);
#endif
}
Exemplo n.º 5
0
sf::FloatRect Ring::getGlobalBounds() const
{
    if (m_vertices.size() == 0)
        return{ { 0.f, 0.f }, { 0.f, 0.f } };

    const sf::Transform transform{ getTransform() };
    sf::Vector2f topLeft{ transform.transformPoint(m_vertices[0].position) };
    sf::Vector2f bottomRight{ topLeft };
    sf::Vector2f current;
    for (auto& vertex : m_vertices)
    {
        current = transform.transformPoint(vertex.position);
        if (current.x < topLeft.x)
            topLeft.x = current.x;
        else if (current.x > bottomRight.x)
            bottomRight.x = current.x;
        if (current.y < topLeft.y)
            topLeft.y = current.y;
        else if (current.y > bottomRight.y)
            bottomRight.y = current.y;
    }
    return{ topLeft, bottomRight - topLeft };
}
Exemplo n.º 6
0
void PointCollider::update (sf::Transform const & root)
{
  worldPos = root.transformPoint(localPos);
}