Пример #1
0
bool RenderTexture::create(unsigned int width, unsigned int height, bool depthBuffer)
{
    // Create the texture
    if (!m_texture.create(width, height))
    {
        err() << "Impossible to create render texture (failed to create the target texture)" << std::endl;
        return false;
    }

    // We disable smoothing by default for render textures
    setSmooth(false);

    // Create the implementation
    delete m_impl;
    if (priv::RenderTextureImplFBO::isAvailable())
    {
        // Use frame-buffer object (FBO)
        m_impl = new priv::RenderTextureImplFBO;
    }
    else
    {
        // Use default implementation
        m_impl = new priv::RenderTextureImplDefault;
    }

    // Initialize the render texture
    if (!m_impl->create(width, height, m_texture.m_texture, depthBuffer))
        return false;

    // We can now initialize the render target part
    RenderTarget::initialize();

    return true;
}
Пример #2
0
void QQuickContext2DTexture::canvasChanged(const QSize& canvasSize, const QSize& tileSize, const QRect& canvasWindow, const QRect& dirtyRect, bool smooth, bool antialiasing)
{
    QSize ts = tileSize;
    if (ts.width() > canvasSize.width())
        ts.setWidth(canvasSize.width());

    if (ts.height() > canvasSize.height())
        ts.setHeight(canvasSize.height());

    setCanvasSize(canvasSize);
    setTileSize(ts);
    setCanvasWindow(canvasWindow);

    if (canvasSize == canvasWindow.size()) {
        m_tiledCanvas = false;
    } else {
        m_tiledCanvas = true;
    }

    if (dirtyRect.isValid())
        setDirtyRect(dirtyRect);

    setSmooth(smooth);
    setAntialiasing(antialiasing);
}
Пример #3
0
void
HrPwWindow::setData(RideItem *ride)
{
    setSmooth(240);
    hrPwPlot->setDataFromRide(ride);
    smallPlot->setData(ride);
}
Пример #4
0
ChartsTimeGraph::ChartsTimeGraph( QQuickItem* parent ) :
    QQuickItem( parent )
{
    setFlag( ItemHasContents, true );
    setSmooth( true );
    setAntialiasing( true );
}
Пример #5
0
void CTexture::load(std::string fileName)
{
	bool isLoaded = loadFromFile(fileName);
#ifdef DEBUG
	assert(isLoaded);
#endif
	setSmooth(true);
	setRepeated(false);
}
Пример #6
0
QStyleItem::QStyleItem(QQuickPaintedItem *parent)
    : QQuickPaintedItem(parent),
    m_styleoption(0),
    m_itemType(Undefined),
    m_sunken(false),
    m_raised(false),
    m_active(true),
    m_selected(false),
    m_focus(false),
    m_hover(false),
    m_on(false),
    m_horizontal(true),
    m_sharedWidget(false),
    m_minimum(0),
    m_maximum(100),
    m_value(0),
    m_step(0),
    m_paintMargins(0),
    m_contentWidth(0),
    m_contentHeight(0)

{
    if (!qApp->style()) {
        qWarning("\nError: No widget style available. \n\nQt Desktop Components "
               "currently depend on the widget module to function. \n"
               "Use QApplication when creating standalone executables.\n\n");
        exit(-1);
    }
    m_font = qApp->font();
    setFlag(QQuickItem::ItemHasContents, true);
    setSmooth(false);

    connect(this, SIGNAL(enabledChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(infoChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(onChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(selectedChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(activeChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(textChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(activeChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(raisedChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(sunkenChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(hoverChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(maximumChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(minimumChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(valueChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(horizontalChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(activeControlChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(hasFocusChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(activeControlChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(elementTypeChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(textChanged()), this, SLOT(updateSizeHint()));
    connect(this, SIGNAL(contentWidthChanged(int)), this, SLOT(updateSizeHint()));
    connect(this, SIGNAL(contentHeightChanged(int)), this, SLOT(updateSizeHint()));
}
Пример #7
0
OgreItem::OgreItem(QQuickItem *parent)
    : QQuickItem(parent)
    , m_timerID(0)
    , m_camera(0)
    , m_ogreEngineItem(0)
{
    setFlag(ItemHasContents);
    setSmooth(false);

    startTimer(16);
}
Пример #8
0
bool System::texture_setSmooth(unsigned int id, bool smooth)
{
    auto texture = mTextureHandler.get(id);

    if(nullptr == texture)
    {
        return false;
    }

    texture->setSmooth(smooth);

    return true;
}
ui_elem_manager::resource
ui_elem_manager::load (const std::string& location)
{
    auto img_res (std::make_shared<sf::Image>());
    if (!img_res->loadFromFile(resource_file(res_ui, location).string()))
        return nullptr;

    auto tx (new sf::Texture);
    tx->loadFromImage(*img_res);
    tx->setSmooth(false);
    auto result (std::make_shared<sf::Sprite>(*tx));
    result->setScale(2, 2);
    return result;
}
Пример #10
0
void ld::PlayState::addEnemy()
{
    if (m_player.getLives() < 1)
        return;
        
    m_enemies.emplace_back(*m_window, Misc::getRandomFloat(m_enemySpeedMin, m_enemySpeed));
	auto& ref = m_enemies.back();

	if (!easterEgg)
	{
		auto tex = ldResource.getTexture("assets/Graphics/Enemies/Alien_1_sheet.png");
		Animation anim;
		anim.load(*tex, 3);
		anim.setChangeTime(0.5f);
		anim.start();
		ref.setAnimation(anim);
		ref.setTexture(tex);
		tex->setSmooth(true);
	}
	else
	{
		auto tex = ldResource.getTexture("assets/Graphics/Enemies/space core.png");
		Animation anim;
		anim.load(*tex, 1);
		anim.setChangeTime(1);
		anim.start();
		ref.setTexture(tex);
		tex->setSmooth(true);
		ref.m_useAnim = false;
		easterEgg = false;
	}
	ref.setSize(sf::Vector2f(148.f, 79.f));
	ref.setOrigin(ref.getSize().x / 2, ref.getSize().y / 2);
	ref.setPosition(getRandSpawnPos());
    ref.setPlayer(&m_player);
}
Пример #11
0
Sample::Sample(float vidWidthPercent, float vidHeightPercent) {
    _vidPercent.set(vidWidthPercent, vidHeightPercent);
    _type = sampleType::LIGHTNESS;
    _radius = 10;
    _valsIndex = 0;
    _selected = false;
    _smooth = 0;
    _name = "";
    _smoothedVals.push_back(SmoothedFloat(1, 0));
    _smoothedVals.push_back(SmoothedFloat(1, 0));
    _smoothedVals.push_back(SmoothedFloat(1, 0));
    _scaleBounds.set(0, 255);
    min = -1;
    max = -1;
    setSmooth(1);
}
Пример #12
0
void ld::PlayState::addExplosion(sf::Vector2f pos)
{
	m_explosions.emplace_back(*m_window);

	auto &ref = m_explosions.back();
	auto tex = ldResource.getTexture("assets/Graphics/Effects/Explosion_sheet.png");
	Animation anim;
	anim.load(*tex, 4);
	anim.setChangeTime(.09f);
	anim.setLooping(false);
	anim.start();
	ref.setAnimation(anim);
	ref.setTexture(tex);
	tex->setSmooth(true);
	ref.setSize(sf::Vector2f(128.f, 128.f));
	ref.setOrigin(ref.getSize().x / 2, ref.getSize().y / 2);
	ref.setPosition(pos);
}
Пример #13
0
PainterBezier::PainterBezier(QQuickItem  *parent)
:QQuickPaintedItem (parent)
,m_p1(QPointF(0.f,0.f))
,m_p2(QPointF(0.f,0.f))
,m_p3(QPointF(0.f,0.f))
,m_p4(QPointF(0.f,0.f))
,m_OutlineColor(Qt::black)
,m_FillColor(QColor(177,189,180))
,m_OutlineWidth(1.f)
,m_FillWidth(3.f)
{
    setX(0);
    setY(0);
    setWidth(1);
    setHeight(1);
    setFlag(ItemHasContents, true);
    //setAntialiasing(true);
    setRenderTarget(QQuickPaintedItem::FramebufferObject);
    setSmooth(true);
}
Пример #14
0
bool MyGLWidget::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: setBox(); break;
    case 1: setWire(); break;
    case 2: setHidden(); break;
    case 3: setFlat(); break;
    case 4: setFlatWire(); break;
    case 5: setSmooth(); break;
    case 6: setSmallTetra(); break;
    case 7: TrackMouseModality(); break;
    case 8: SectionMouseModality(); break;
    case 9: SwitchTextSimplex(); break;
    case 10: SwitchTextPhysics(); break;
    case 11: SwitchTextQuality(); break;
    default:
	return QGLWidget::qt_invoke( _id, _o );
    }
    return TRUE;
}
Пример #15
0
QStyleItem::QStyleItem(QDeclarativeItem *parent)
    : QDeclarativeItem(parent),
    m_dummywidget(0),
    m_styleoption(0),
    m_type(Undefined),
    m_sunken(false),
    m_raised(false),
    m_active(true),
    m_selected(false),
    m_focus(false),
    m_on(false),
    m_horizontal(true),
    m_sharedWidget(false),
    m_minimum(0),
    m_maximum(100),
    m_value(0),
    m_paintMargins(0)
{
    setFlag(QGraphicsItem::ItemHasNoContents, false);
    setCacheMode(QGraphicsItem::DeviceCoordinateCache);
    setSmooth(true);

    connect(this, SIGNAL(infoChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(onChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(selectedChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(activeChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(textChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(activeChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(raisedChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(sunkenChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(hoverChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(maximumChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(minimumChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(valueChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(horizontalChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(activeControlChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(focusChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(activeControlChanged()), this, SLOT(updateItem()));
    connect(this, SIGNAL(elementTypeChanged()), this, SLOT(updateItem()));
}
Пример #16
0
	CubeTexture &CubeTexture::operator=(const CubeTexture &cubeTex)
	{
		FRONTIER_HEAVYCOPY_NOTE;
		
		if (cubeTex.getGlId())
		{
			create(cubeTex.getSize());
			C(6)
				getFace(i).copyFace(cubeTex,i);
		}
		else
		{
			if (getGlId() && glIsTexture(getGlId()) == GL_TRUE)
				glDeleteTextures(1,&getGlId());
			
			getGlId() = 0;
			m_size    = 0;
		}
		
		setRepeated(cubeTex.m_isRepeated);
		setSmooth(cubeTex.m_isSmooth);
	}
Пример #17
0
  Block::Block(int index, Game *game, const TileParam &tileParam)
    : Body(Body::BodyType::Block, game, tileParam)
    , mGravityScale(2.f)
    , mMinimumHitImpulse(0)
  {
    mName = Name;
    mMinimumHitImpulse = mTileParam.minimumHitImpulse;
    setScore(mTileParam.score);
    setEnergy(mTileParam.minimumKillImpulse);
    setGravityScale(mTileParam.gravityScale);

    const sf::Texture &texture = mGame->level()->tileParam(index).texture;
    sf::Image img;
    img.create(texture.getSize().x + 2 * TextureMargin, texture.getSize().y + 2 * TextureMargin, sf::Color(0, 0, 0, 0));
    img.copy(texture.copyToImage(), TextureMargin, TextureMargin, sf::IntRect(0, 0, 0, 0), true);
    mTexture.loadFromImage(img);
    setSmooth(mTileParam.smooth);

    setHalfTextureSize(texture);
    
    mSprite.setTexture(mTexture);
    mSprite.setOrigin(.5f * mTexture.getSize().x, .5f * mTexture.getSize().y);

    if (gLocalSettings().useShaders()) {
      mShader.loadFromFile(ShadersDir + "/fallingblock.fs", sf::Shader::Fragment);
      mShader.setParameter("uAge", 0.f);
      mShader.setParameter("uBlur", 0.f);
      mShader.setParameter("uColor", sf::Color(255U, 255U, 255U, 255U));
      mShader.setParameter("uResolution", float(mTexture.getSize().x), float(mTexture.getSize().y));
    }

    const unsigned int W = texture.getSize().x;
    const unsigned int H = texture.getSize().y;

    b2BodyDef bd;
    bd.type = b2_dynamicBody;
    bd.angle = .0f;
    bd.linearDamping = mTileParam.linearDamping.isValid() ? mTileParam.linearDamping.get() : DefaultLinearDamping;
    bd.angularDamping = mTileParam.angularDamping.isValid() ? mTileParam.angularDamping.get() : DefaultAngularDamping;
    bd.gravityScale = .0f;
    bd.allowSleep = true;
    bd.awake = false;
    bd.fixedRotation = false;
    bd.bullet = false;
    bd.userData = this;
    mBody = game->world()->CreateBody(&bd);

    b2PolygonShape polygon;
    const float32 hs = .5f * Game::InvScale;
    const float32 hh = hs * H;
    const float32 xoff = hs * (W - H);
    polygon.SetAsBox(xoff, hh);

    const float32 density = mTileParam.density.isValid() ? mTileParam.density.get() : DefaultDensity;
    const float32 friction = mTileParam.friction.isValid() ? mTileParam.friction.get() : DefaultFriction;
    const float32 restitution = mTileParam.restitution.isValid() ? mTileParam.restitution.get() : DefaultRestitution;

    b2FixtureDef fdBox;
    fdBox.shape = &polygon;
    fdBox.density = density;
    fdBox.friction = friction;
    fdBox.restitution = restitution;
    fdBox.userData = this;
    mBody->CreateFixture(&fdBox);

    b2CircleShape circleL;
    circleL.m_p.Set(-xoff, 0.f);
    circleL.m_radius = hh;

    b2FixtureDef fdCircleL;
    fdCircleL.shape = &circleL;
    fdCircleL.density = density;
    fdCircleL.friction = friction;
    fdCircleL.restitution = restitution;
    fdCircleL.userData = this;
    mBody->CreateFixture(&fdCircleL);

    b2CircleShape circleR;
    circleR.m_p.Set(xoff, 0.f);
    circleR.m_radius = hh;

    b2FixtureDef fdCircleR;
    fdCircleR.shape = &circleR;
    fdCircleR.density = density;
    fdCircleR.friction = friction;
    fdCircleR.restitution = restitution;
    fdCircleR.userData = this;
    mBody->CreateFixture(&fdCircleR);
  }
Пример #18
0
GraphView::GraphView( QQuickItem* parent ) :
    qan::Navigable{ parent }
{
    setAntialiasing( true );
    setSmooth( true );
}
Пример #19
0
		//  [8/18/2008 zhangxiang]
		sgMeshPlane::sgMeshPlane()
		: sgMesh()
	{
		UInt32 aiLengthPerUnit = 50;
		UInt32 aiHUnitNum = 50;
		UInt32 aiVUnitNum = 50;
		//reset(2, 2 * (aiHUnitNum + aiVUnitNum), aiHUnitNum + aiVUnitNum + 2);
		reset(4, aiHUnitNum * aiVUnitNum * 4, aiHUnitNum * aiVUnitNum);

		int hTotalLength = aiLengthPerUnit * aiHUnitNum;
		int vTotalLength = aiLengthPerUnit * aiVUnitNum;
		int hHalfTotalLength = hTotalLength * 0.5;
		int vHalfTotalLength = vTotalLength * 0.5;

		Vector3 *pPosData = static_cast<Vector3*>(m_pVertexData->createElement(sgVertexBufferElement::VertexAttributeName, RDT_F, 3, m_iVertexNum)->data());
		Vector2 *pUV0Data = static_cast<Vector2*>(m_pVertexData->createElement(sgVertexBufferElement::UV0AttributeName, RDT_F, 2, m_iVertexNum)->data());
		//Color *pColorData = static_cast<Color*>(m_pVertexData->createElement(sgVertexBufferElement::ET_COLOR, 4, m_iVertexNum)->data());
		size_t *pIndex = static_cast<size_t*>(m_pIndexData->createElement(sgVertexBufferElement::ET_VERTEX)->data());
        
        Int32 xLeft = -hHalfTotalLength;
        Int32 zTop = -vHalfTotalLength;
        UInt32 iVertex = 0;
        for(UInt32 row=0; row<aiVUnitNum; ++row, zTop+=aiLengthPerUnit)
        {
            xLeft = -hHalfTotalLength;
            for(UInt32 col=0; col<aiHUnitNum; ++col, xLeft+=aiLengthPerUnit, iVertex+=4)
            {
                pPosData[iVertex] = Vector3(xLeft, 0.0f, zTop);
                pPosData[iVertex+1] = Vector3(xLeft, 0.0f, zTop+(Int32)aiLengthPerUnit);
                pPosData[iVertex+2] = Vector3(xLeft+(Int32)aiLengthPerUnit, 0.0f, zTop+(Int32)aiLengthPerUnit);
                pPosData[iVertex+3] = Vector3(xLeft+(Int32)aiLengthPerUnit, 0.0f, zTop);
                
                pUV0Data[iVertex] = Vector2(0.0f, 0.0f);
                pUV0Data[iVertex+1] = Vector2(0.0f, 1.0f);
                pUV0Data[iVertex+2] = Vector2(1.0f, 1.0f);
                pUV0Data[iVertex+3] = Vector2(1.0f, 0.0f);
                
                pIndex[iVertex] = iVertex;
                pIndex[iVertex+1] = iVertex+1;
                pIndex[iVertex+2] = iVertex+2;
                pIndex[iVertex+3] = iVertex+3;
            }
        }
		/*
		pPosData[0] = Vector3(-hHalfTotalLength, 0.0f, -vHalfTotalLength);
		pPosData[1] = Vector3(-hHalfTotalLength, 0.0f, vHalfTotalLength);
		pPosData[2] = Vector3(hHalfTotalLength, 0.0f, vHalfTotalLength);
		pPosData[3] = Vector3(hHalfTotalLength, 0.0f, -vHalfTotalLength);

		pUV0Data[0] = Vector2(0.0f, 0.0f);
		pUV0Data[1] = Vector2(0.0f, 1.0f);
		pUV0Data[2] = Vector2(1.0f, 1.0f);
		pUV0Data[3] = Vector2(0.0f, 0.0f);

		pIndex[0] = 0;
		pIndex[1] = 1;
		pIndex[2] = 2;
		pIndex[3] = 3;
         */

		m_bNormalOuter = true;
        setSmooth(false);

		prepareGeometry();
	}
Пример #20
0
	//  [1/5/2009 zhangxiang]
	void sgMeshCube::init(void){

		Real halfLength = m_fEdgeLength * 0.5f;

		Vector3 *pPosData = static_cast<Vector3*>(m_pVertexData->createElement(sgVertexBufferElement::VertexAttributeName, RDT_F, 3, m_iVertexNum)->data());
		size_t *pIndexData = static_cast<size_t*>(m_pIndexData->createElement(sgVertexBufferElement::ET_VERTEX)->data());

		// setup vertecies
		pPosData[0] = Vector3(-halfLength, -halfLength, halfLength);
		pPosData[1] = Vector3(halfLength, -halfLength, halfLength);
		pPosData[2] = Vector3(halfLength, halfLength, halfLength);
		pPosData[3] = Vector3(-halfLength, halfLength, halfLength);

		pPosData[4] = Vector3(-halfLength, halfLength, -halfLength);
		pPosData[5] = Vector3(halfLength, halfLength, -halfLength);
		pPosData[6] = Vector3(halfLength, -halfLength, -halfLength);
		pPosData[7] = Vector3(-halfLength, -halfLength, -halfLength);

		// setup faces
		pIndexData[0] = 0;
		pIndexData[1] = 1;
		pIndexData[2] = 2;

		pIndexData[3] = 2;
		pIndexData[4] = 3;
		pIndexData[5] = 0;

		pIndexData[6] = 0;
		pIndexData[7] = 7;
		pIndexData[8] = 6;

		pIndexData[9] = 6;
		pIndexData[10] = 1;
		pIndexData[11] = 0;

		pIndexData[12] = 4;
		pIndexData[13] = 5;
		pIndexData[14] = 6;

		pIndexData[15] = 6;
		pIndexData[16] = 7;
		pIndexData[17] = 4;

		pIndexData[18] = 4;
		pIndexData[19] = 7;
		pIndexData[20] = 0;

		pIndexData[21] = 0;
		pIndexData[22] = 3;
		pIndexData[23] = 4;

		pIndexData[24] = 5;
		pIndexData[25] = 4;
		pIndexData[26] = 3;

		pIndexData[27] = 3;
		pIndexData[28] = 2;
		pIndexData[29] = 5;

		pIndexData[30] = 2;
		pIndexData[31] = 1;
		pIndexData[32] = 6;

		pIndexData[33] = 6;
		pIndexData[34] = 5;
		pIndexData[35] = 2;

        setSmooth(false);
		//setupNormals();
		//	computeEdgeNormal(); for future ...
		prepareGeometry();
	}
Пример #21
0
bool ld::PlayState::init()
{
    std::srand(static_cast<unsigned int>(std::time(0)));
    
    if (m_music.openFromFile("assets/Audio/Music/Abstraction - Ludum Dare 28 - First Track.wav"))
        m_music.play();
    m_music.setLoop(true);

    const float buttonScale = 2.f;
    // Pause menu
    {
        std::array<std::unique_ptr<Button>, 3> buttons;

        for (auto& i : buttons)
        {
            i.reset(new Button(*m_window));

            i->setFillColor(sf::Color(255, 255, 255, 255));
            i->setSound("assets/Audio/Sound Effects/menuselect.ogg");
        }
        const float buttonOffset = 50.f;

        /****** Resume button ******/
        auto tex = ldResource.getTexture("assets/Graphics/Menus/retry.png");
        buttons[0]->setTexture(tex);
        buttons[0]->setSize(sf::Vector2f(tex->getSize()) * buttonScale);
        buttons[0]->setPosition(100.f, 100.f);
        buttons[0]->setCallback([this]()
        {
            m_menuState = Count;
            Engine::getInstance().setPaused(false);
        });

        /****** Restart button ******/
        tex = ldResource.getTexture("assets/Graphics/Menus/restart.png");
        buttons[1]->setTexture(tex);
        buttons[1]->setSize(buttons[0]->getSize());
        buttons[1]->setPosition(100.f, buttons[0]->getPosition().y + buttons[0]->getSize().y + buttonOffset);
        buttons[1]->setCallback([this]()
        {
            auto ptr = new PlayState(*m_window);
            ptr->setDifficulty(m_difficulty);
            Engine::getInstance().changeState(ptr);
            Engine::getInstance().setPaused(false);
        });

        /****** Exit button ******/
        tex = ldResource.getTexture("assets/Graphics/Menus/backToMenu.png");
        buttons[2]->setTexture(tex);
        buttons[2]->setSize(buttons[1]->getSize());
        buttons[2]->setPosition(100.f, buttons[1]->getPosition().y + buttons[1]->getSize().y + buttonOffset);
        buttons[2]->setCallback([this]()
        {
            Engine::getInstance().changeState(new MainMenuState(*m_window));
            Engine::getInstance().setPaused(false);
        });

        for (auto& i : buttons)
            m_menus[Pause]->addElement(i.release());
    }

    // Game over menu
    {
        std::array<std::unique_ptr<Button>, 2> buttons;

        for (auto& i : buttons)
        {
            i.reset(new Button(*m_window));

            i->setFillColor(sf::Color(255, 255, 255, 255));
            i->setSound("assets/Audio/Sound Effects/menuselect.ogg");
        }

        const float buttonOffset = 50.f;

        /****** Restart button ******/
        auto tex = ldResource.getTexture("assets/Graphics/Menus/restart.png");
        buttons[0]->setTexture(tex);
        buttons[0]->setSize(sf::Vector2f(tex->getSize()) * buttonScale);
        buttons[0]->setPosition(100.f, 100.f);
        buttons[0]->setCallback([this]()
        {
            auto ptr = new PlayState(*m_window);
            ptr->setDifficulty(m_difficulty);

            Engine::getInstance().changeState(ptr);
            Engine::getInstance().setPaused(false);
        });

        /****** Quit button ******/
        tex = ldResource.getTexture("assets/Graphics/Menus/backToMenu.png");
        buttons[1]->setTexture(tex);
        buttons[1]->setSize(buttons[0]->getSize());
        buttons[1]->setPosition(100.f, buttons[0]->getPosition().y + buttons[0]->getSize().y + buttonOffset);
        buttons[1]->setCallback([this]()
        {
            Engine::getInstance().changeState(new MainMenuState(*m_window));
            Engine::getInstance().setPaused(false);
        });

        for (auto& i : buttons)
            m_menus[GameOver]->addElement(i.release());
    }

	//Player
	auto tex = ldResource.getTexture("assets/Graphics/Player and shield planets/Player_Base.png");
	tex->setSmooth(true);
	m_player.setTexture(tex);
	m_player.setSize(sf::Vector2f(128.f,128.f));
	m_player.setOrigin(m_player.getSize().x / 2, m_player.getSize().y / 2);
	m_player.setPosition(m_window->getView().getCenter());

	tex = ldResource.getTexture("assets/Graphics/Player and shield planets/Shield.png");
	tex->setSmooth(true);
	m_player.m_shield.setTexture(tex);
	m_player.m_shield.setSize(sf::Vector2f(128.f, 128.f));
	m_player.m_shield.setOrigin(m_player.m_shield.getSize().x / 2, m_player.m_shield.getSize().y / 2);
	m_player.m_shield.setPosition(m_player.getPosition() - m_player.getSize());

	tex = ldResource.getTexture("assets/Graphics/Effects/electricity_chain_loop.png");
	tex->setSmooth(true);
	tex->setRepeated(true);
	m_player.m_chain.setTexture(tex);
	m_player.m_chain.setSize(sf::Vector2f(200, 200));
	m_player.m_chain.setOrigin(m_player.m_chain.getSize().x / 2, 0);
	m_player.m_chain.setPosition(m_player.getPosition());

    tex = ldResource.getTexture("assets/Graphics/Player and shield planets/Player_Cloud.png");
    tex->setSmooth(true);
    m_player.m_clouds.setTexture(tex);
    m_player.m_clouds.setSize(m_player.getSize());
    m_player.m_clouds.setScale(m_player.getScale());
    m_player.m_clouds.setOrigin(m_player.getSize() / 2.f);
    m_player.m_clouds.setPosition(m_player.getPosition());
	
    tex = ldResource.getTexture("assets/Graphics/Backgrounds/background.png");
    tex->setSmooth(true);
    m_background.setSize(m_window->getView().getSize());
    m_background.setTexture(tex);

    tex = ldResource.getTexture("assets/Graphics/Menus/healthcounter.png");
    tex->setSmooth(true);
    m_lifeIcon.setTexture(tex);
    m_lifeIcon.setSize(sf::Vector2f(m_lifeIcon.getTexture()->getSize()));

    tex = ldResource.getTexture("assets/Graphics/Menus/killcounter.png");
    tex->setSmooth(true);
    m_killIcon.setTexture(tex);
    m_killIcon.setSize(sf::Vector2f(m_killIcon.getTexture()->getSize()));

    auto font = ldResource.getFont("assets/Graphics/Roboto-Black.ttf");
    m_scoreText.setFont(*font);
    m_scoreText.setCharacterSize(50);
    m_scoreText.setColor(sf::Color(255, 255, 255, 255));

    m_killsText.setFont(*font);
    m_killsText.setCharacterSize(65);
    m_killsText.setColor(sf::Color(255, 255, 255, 255));

    switch (m_difficulty)
    {
        case 1:
            m_Time = 6.f;
            m_minTime = 3.f;
			m_player.setLives(5);
			m_enemySpeed = 150.f;
			m_enemySpeedMin = 100.f;
			break;
        case 2:
            m_Time = 3.5f;
            m_minTime = 1.f;
            m_player.setLives(4);
			m_enemySpeed = 185.f;
			m_enemySpeedMin = 100.f;
            break;
        case 3:
            m_Time = 2.5f;
            m_minTime = 0.25f;
			m_player.setLives(3);
			m_enemySpeed = 225.f;
			m_enemySpeedMin = 100.f;
            break;
		default:
			assert(false);
			break;
    }

    m_scoreClock.restart();

	//Enemy
	addEnemy();

	return true;
}
Пример #22
0
  Racket::Racket(Game *game, const b2Vec2 &pos, b2Body *ground, const TileParam &tileParam)
    : Body(Body::BodyType::Racket, game, tileParam)
  {
    mName = Name;
    mTexture = mGame->level()->texture(mName);
    setSmooth(mTileParam.smooth);
    mSprite.setTexture(mTexture);
    mSprite.setOrigin(sf::Vector2f(.5f * mTexture.getSize().x, .5f * mTexture.getSize().y));

    setHalfTextureSize(mTexture);

    b2BodyDef bd;
    bd.type = b2_dynamicBody;
    bd.gravityScale = 0.f;
    mTiltingBody = mGame->world()->CreateBody(&bd);

    b2PolygonShape polygon;
    const float32 hs = .5f * Game::InvScale;
    const float32 hh = hs * mTexture.getSize().y;
    const float32 xoff = hs * (mTexture.getSize().x - mTexture.getSize().y);
    polygon.SetAsBox(xoff, hh);

    const float32 density = tileParam.density.isValid() ? tileParam.density.get() : DefaultDensity;
    const float32 friction = tileParam.friction.isValid() ? tileParam.friction.get() : DefaultFriction;
    const float32 restitution = tileParam.restitution.isValid() ? tileParam.restitution.get() : DefaultRestitution;

    b2FixtureDef fdBox;
    fdBox.shape = &polygon;
    fdBox.density = density;
    fdBox.friction = friction;
    fdBox.restitution = restitution;
    fdBox.userData = this;
    mTiltingBody->CreateFixture(&fdBox);

    b2CircleShape circleL;
    circleL.m_p.x = -xoff;
    circleL.m_radius = hh;

    b2FixtureDef fdCircleL;
    fdCircleL.shape = &circleL;
    fdCircleL.density = density;
    fdCircleL.friction = friction;
    fdCircleL.restitution = restitution;
    fdCircleL.userData = this;
    mTiltingBody->CreateFixture(&fdCircleL);

    b2CircleShape circleR;
    circleR.m_p.x = xoff;
    circleR.m_radius = hh;

    b2FixtureDef fdCircleR;
    fdCircleR.shape = &circleR;
    fdCircleR.density = density;
    fdCircleR.friction = friction;
    fdCircleR.restitution = restitution;
    fdCircleR.userData = this;
    mTiltingBody->CreateFixture(&fdCircleR);

    b2BodyDef bdHinge;
    bdHinge.type = b2_dynamicBody;
    mBody = mGame->world()->CreateBody(&bdHinge);

    b2RevoluteJointDef rjd;
    rjd.Initialize(mBody, mTiltingBody, b2Vec2_zero);
    rjd.enableMotor = true;
    rjd.maxMotorTorque = 20000.0f; //MOD Drehmoment
    rjd.enableLimit = true;
    rjd.lowerAngle = deg2rad(-17.5f); //MOD Anschlagswinkel in Grad
    rjd.upperAngle = deg2rad(+17.5f); //MOD Anschlagswinkel in Grad
    mJoint = reinterpret_cast<b2RevoluteJoint*>(mGame->world()->CreateJoint(&rjd));

    b2MouseJointDef mjd;
    mjd.bodyA = ground;
    mjd.bodyB = mTiltingBody;
    mjd.collideConnected = true;
    mjd.frequencyHz = 6.f; //MOD
    mjd.dampingRatio = .95f; //MOD
    mjd.maxForce = 1000.f * mTiltingBody->GetMass(); //MOD
    mMouseJoint = reinterpret_cast<b2MouseJoint*>(mGame->world()->CreateJoint(&mjd));

    setPosition(pos);
  }
Пример #23
0
void
HrPwWindow::setrSmoothingFromLineEdit()
{
    int _smooth = rSmoothEdit->text().toInt();
    setSmooth(_smooth);
}
Пример #24
0
void sfRenderTexture_setSmooth(sfRenderTexture* renderTexture, sfBool smooth)
{
    CSFML_CALL(renderTexture, setSmooth(smooth == sfTrue));
}
Пример #25
0
void
HrPwWindow::setrSmoothingFromSlider()
{
    setSmooth(rSmoothSlider->value());
}