Ejemplo n.º 1
0
bool	RectangleBlock::RectangleEquality(const sf::Shape& a, const sf::Shape& b) {
	if(a.GetNbPoints() != b.GetNbPoints() ) return false;

	for(int i=0;i<a.GetNbPoints();i++) {			//egyesével megvizsgáljuk
		if(a.GetPointPosition(i) != b.GetPointPosition(i)) {
			return false;
		}
	}
	return true;
}
Ejemplo n.º 2
0
sf::Vector2f GetShapeSize(sf::Shape& s){
    sf::Vector2f Min={0.f,0.f},Max=Min;
    for(unsigned int a=0;a<s.GetNbPoints();a++){
        auto it=s.GetPointPosition(a);
        if(it.x<Min.x)Min.x=it.x;
        if(it.y<Min.y)Min.y=it.y;
        if(it.x>Max.x)Max.x=it.x;
        if(it.y>Max.y)Max.y=it.y;
    }
    return Max-Min;
}
Ejemplo n.º 3
0
void GUI::Game::Object::draw(sf::RenderWindow& window, boost::shared_ptr<const ::Game::Player> viewer, bool selected) {
    // TODO: Load real graphics and track animations.
    static sf::Shape tmp, circle;
    if (!tmp.GetNbPoints()) {
        tmp.AddPoint(-0.8, -0.4);
        tmp.AddPoint(-0.0, -0.4);
        tmp.AddPoint(-0.0, -0.8);
        tmp.AddPoint(+0.8, -0.0);
        tmp.AddPoint(-0.0, +0.8);
        tmp.AddPoint(-0.0, +0.4);
        tmp.AddPoint(-0.8, +0.4);
        tmp.SetOutlineWidth(0.15);
    }
    if (!circle.GetNbPoints()) {
        circle = sf::Shape::Circle(0, 0, 1, sf::Color(0xff, 0xff, 0xff, 0x44), 0.2, sf::Color(0xff, 0xff, 0xff, 0xdd));
    }

    Vector2<SIUnit::Position> pos = object->getPosition();
    double r = object->getObjectType()->radius.getDouble();

    if (object->getOwner() == viewer) {
        circle.SetColor(sf::Color(0x33, 0x33, 0xcc));
        tmp.SetColor(sf::Color(0x33, 0x33, 0xcc));
    } else {
        circle.SetColor(sf::Color(0xcc, 0x33, 0x00));
        tmp.SetColor(sf::Color(0xdd, 0x00, 0x00));
    }

    if (selected) {
        circle.SetScale(r, r);
        circle.SetPosition(pos.x.getDouble(), pos.y.getDouble());
        window.Draw(circle);
    }

    tmp.SetScale(r, r);
    tmp.SetPosition(pos.x.getDouble(), pos.y.getDouble());
    tmp.SetRotation(-Math::toDegrees(object->getDirection().getDouble()));
    window.Draw(tmp);
}