Arvid::Arvid(sf::Vector2f &position) /*:
	mIdleLeftAnimation	("", 0, 0),
	mIdleRightAnimation ("", 0, 0),
	mRunLeftAnimation	("", 0, 0),
	mRunRightAnimation	("", 0, 0),
	mJumpAnimation		("", 0, 0)*/
{ 
	mEntityKind = ARVID;
	setPosition(position);
	TEXTURE.loadFromFile("GUBBJEVEL.png");
	SPRITE.setTexture(TEXTURE);
	mHitBox.width = SPRITE.getLocalBounds().width;
	mHitBox.height = SPRITE.getLocalBounds().height;
	SPRITE.setPosition(position);
}
Exemple #2
0
 SpriteNode(const sf::Texture& t,
            sf::Vector2f pos)
 : mSprite(t)
 {
    sf::FloatRect bounds = mSprite.getLocalBounds();
    mSprite.setOrigin(bounds.width / 2.f, bounds.height / 2.f);
    mSprite.setPosition(pos);
 };
void WindowCreateThing::init(sf::RenderWindow &window) {

    rectTitle.setSize(sf::Vector2f(window.getSize().x*0.45, window.getSize().y*0.07));
    rectTitle.setPosition(sf::Vector2f(window.getSize().x/2-(rectTitle.getSize().x/2), window.getSize().x/4-(rectTitle.getSize().y/2)));
    rectTitle.setFillColor(sf::Color(158, 158, 158));
    rectTitle.setOutlineColor(sf::Color::Black);
    rectTitle.setOutlineThickness(1.f);

    rectMain.setSize(sf::Vector2f(window.getSize().x*0.45,window.getSize().y*0.45));
    rectMain.setPosition(sf::Vector2f(rectTitle.getPosition().x, rectTitle.getPosition().y+rectTitle.getSize().y));
    rectMain.setFillColor(sf::Color::White);
    rectMain.setOutlineColor(sf::Color::Black);
    rectMain.setOutlineThickness(1.f);

    load();


    starting_position = sf::Mouse::getPosition(window);



    textTitle.setFont(font);
    textTitle.setString("CreateThings.txt");
    textTitle.setCharacterSize(24);
    textTitle.setColor(sf::Color::White);
    textTitle.setPosition(sf::Vector2f(rectTitle.getPosition().x+rectTitle.getSize().x*0.3, rectTitle.getPosition().y+rectTitle.getSize().y*0.1));
    //textTitle.setPosition(sf::Vector2f(400,10));

    textClose.setFont(font);
    textClose.setString("X");
    textClose.setStyle(sf::Text::Bold);
    textClose.setCharacterSize(35);
    textClose.setColor(sf::Color::White);
    textClose.setPosition(sf::Vector2f(rectTitle.getPosition().x+rectTitle.getSize().x-30, rectTitle.getPosition().y+rectTitle.getSize().y*0.05));


    ///// FOLDER ICONE
    textureFolder.setSmooth(true);
    spriteFodler.setTexture(textureFolder);
    sf::Vector2f targetSize(25.0f, 25.0f);
    spriteFodler.setScale(
        targetSize.x / spriteFodler.getLocalBounds().width,
        targetSize.y / spriteFodler.getLocalBounds().height);
    spriteFodler.setPosition(sf::Vector2f(textTitle.getPosition().x-targetSize.x, textTitle.getPosition().y));




    ///// CLOSE ICONE
    /*textureClose.setSmooth(true);
    spriteClose.setTexture(textureClose);
    sf::Vector2f targetSize2(window.getSize().y*0.07, window.getSize().y*0.07);
    spriteClose.setScale(
        targetSize2.x / spriteClose.getLocalBounds().width,
        targetSize2.y / spriteClose.getLocalBounds().height);
    spriteClose.setPosition(rectTitle.getPosition().x+rectTitle.getSize().x-targetSize2.x, rectTitle.getPosition().y);*/
}
                                Scenery(LevelBlock* host
                                        , const sf::Texture& texture)
                                : mHostBlock(host)
                                , mSprite(texture)
                                {
                                    sf::FloatRect bounds = mSprite.getLocalBounds();
                                    mSprite.setOrigin(bounds.width / 2.f, bounds.height / 2.f);

                                    mSprite.move(20.f, 20.f);
                                };
bool Entity::isInViewingDistance(sf::Sprite opponent) {


	sf::Vector2f position = opponent.getPosition();
	sf::FloatRect bounds = opponent.getLocalBounds();
	const sf::Rect<float> opponents_rect(position.x, position.y, 32, 32);
	return false;
	//return perimeter.intersects(opponents_rect);

}
	void set_origin()
	{
		
		const float mult{0.27f};
		assert(mult > 0.0f);
		
		const sf::FloatRect m_image_bounds{m_sprite.getLocalBounds()};		
		m_sprite.setOrigin(0.5f*m_image_bounds.width, 0.5f*m_image_bounds.height);
		m_radius = mult*(m_image_bounds.width + m_image_bounds.height);
		
	}
Exemple #7
0
Collision::OBB Collision::getOBB(const sf::Sprite& object){
	//Gets the oriented bounding box of object, which is the local bounds of the object rotated
	sf::FloatRect box(object.getLocalBounds());
	maths::Vector2 topleft, botright, topright, botleft;

	float rot = object.getRotation();
	maths::Vector2 origin = object.getOrigin();
	maths::Vector2 position = object.getPosition();
	
	//Get rotated coordinates of vertices
	topleft = position + maths::Vector2(box.left, box.top).rotate(rot, origin);
	botright = position + maths::Vector2(box.left + box.width, box.top + box.height).rotate(rot, origin);
	topright = position + maths::Vector2(box.left + box.width, box.top).rotate(rot, origin);
	botleft = position + maths::Vector2(box.left, box.top + box.height).rotate(rot, origin);


	return OBB(topleft, botleft, topright, botright);
}
Exemple #8
0
    EnergyMeter::EnergyMeter(const sf::Sprite &overlay, const float &maximumValue)
        : value(maximumValue)
        , maximumValue(maximumValue)
        , orientation(-1)
        , overlay(overlay)
        , primaryColor(DEFAULT_PRIMARY_COLOR)
        , secondaryColor(DEFAULT_SECONDARY_COLOR)
        , fillColor(DEFAULT_FILL_COLOR)
    {
        setVisible(true);

        foreground.setSize(
            sf::Vector2f(
                overlay.getLocalBounds().width,
                overlay.getLocalBounds().height
            )
        );

        primaryBackground.setSize(foreground.getSize());

        secondaryBackground.setSize(
            sf::Vector2f(
                2.0f,
                foreground.getSize().y
            )
        );

        setFillColor(fillColor);
        setPrimaryColor(primaryColor);
        setSecondaryColor(secondaryColor);

        setPosition(
            sf::Vector2i(
                static_cast<int>(overlay.getPosition().x),
                static_cast<int>(overlay.getPosition().y)
            )
        );

        setOrientation(VERTICAL_ORIENTATION);

        updateFill();
    }
                                        Entity(sf::Texture& sTexture, EntityType type, Collidable::Type colType, sf::SoundBuffer& soundBuf1, sf::SoundBuffer& soundBuf2)
                                        : Collidable(colType)
                                        , mSprite(sTexture)
                                        , mDeathSound(soundBuf1)
                                        , mLaserSound(soundBuf2)
                                        , mType(type)
                                        , mCollected(0)
                                        , mFireProjectile(false)
                                        , mFireCountdown(sf::Time::Zero)
                                        {
                                            sf::FloatRect bounds = mSprite.getLocalBounds();
                                            mSprite.setOrigin(bounds.width / 2.f, bounds.height / 2.f);

                                            switch(type)
                                            {
                                                case EntityType::Player: mHitPoints = PlayerHitPoints; break;
                                                case EntityType::Enemy: mHitPoints = EnemyHitPoints; break;
                                                default: break;
                                            }

                                            mLaserSound.setVolume(75.f);
                                            mDeathSound.setVolume(75.f);
                                        };
void TEALShow::OrientedBox( sf::Sprite &s, sf::Color col)
{
	AddTransformedRectanglePoints( s.getLocalBounds(), s.getTransform(), col );
}
Exemple #11
0
void centerOrigin(sf::Sprite& sprite)
{
    sf::FloatRect bounds = sprite.getLocalBounds();
    sprite.setOrigin(bounds.left + bounds.width / 2.f, bounds.top + bounds.height / 2.f);
}
bool MapEditor::isSpriteClicked(sf::Sprite& spr, sf::Vector2f *mousePos){
	return mousePos->x > spr.getPosition().x
		&& mousePos->x < spr.getPosition().x + spr.getLocalBounds().width
		&& mousePos->y > spr.getPosition().y
		&& mousePos->y < spr.getPosition().y + spr.getLocalBounds().height;
}
Exemple #13
0
 void CenterSprite(sf::Sprite& sprite, const sf::RenderTarget& target)
 {
     sf::FloatRect sprite_bounds = sprite.getLocalBounds();
     sprite.setOrigin(sprite_bounds.left + (sprite_bounds.width/2.0f), sprite_bounds.top + (sprite_bounds.height/2.0f));
     sprite.setPosition(sf::Vector2f(target.getSize() / (unsigned)2));
 }
Exemple #14
0
 void CenterSpriteVert(sf::Sprite& sprite, const sf::RenderTarget& target)
 {
     sf::FloatRect sprite_bounds = sprite.getLocalBounds();
     sprite.setOrigin(0, sprite_bounds.top + (sprite_bounds.height/2.f));
     sprite.setPosition(sprite.getPosition().x, target.getSize().y/2.f);
 }
Exemple #15
0
 void CenterSpriteHor(sf::Sprite& sprite, const sf::RenderTarget& target)
 {
     sf::FloatRect sprite_bounds = sprite.getLocalBounds();
     sprite.setOrigin(sprite_bounds.left + (sprite_bounds.width/2.f), 0);
     sprite.setPosition(target.getSize().x/2.f, sprite.getPosition().y);
 }
Exemple #16
0
sf::FloatRect Collision::getOriginalBoundingBox(const sf::Sprite& object){
	//Get unrotated bounding box in world coordinates
	sf::FloatRect rect = object.getLocalBounds();
	maths::Vector2 tl = object.getPosition() - object.getOrigin() + maths::Vector2(rect.left, rect.top);
	return sf::FloatRect(tl.x, tl.y, rect.width, rect.height);
}
void MameUIsenWindow::centerElement(sf::Sprite& sprite)
{
	sf::FloatRect fr = sprite.getLocalBounds();
	sprite.setOrigin(fr.left + fr.width/2.0f, fr.top + fr.height/2.0f);
}
	sf::FloatRect get_sizes()
	{
		
		return m_sprite.getLocalBounds();
		
	}
Exemple #19
0
inline void centerOrigin(sf::Sprite& sprite)
{
	sf::FloatRect bounds = sprite.getLocalBounds();
	sprite.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
}
Exemple #20
0
 sf::FloatRect              getLocalBounds() {return mSprite.getLocalBounds();}