//-----------------------------------------------------------------------------
// Purpose: Update all deltas that are not expired.
//-----------------------------------------------------------------------------
void CTextManager::Update( void )
{
	for ( int i = 0; i < 10; i++ )
	{
		if ( m_aTexts[i].flDieTime < g_CurTime )
			continue;

		sf::Color deltaColor( 255, 15, 15, 255 );

		float flLifetimePercent = ( m_aTexts[i].flDieTime - g_CurTime ) / 1.5f;

		if ( flLifetimePercent < 0.5f )
		{
			deltaColor.a = (char)( 255.0f * ( flLifetimePercent / 0.5 ) );
		}

		if ( !m_aTexts[i].bMinus )
		{
			deltaColor.r = (char)RemapValClamped( flLifetimePercent, 0.0f, 1.0f, 255, 30 );
			deltaColor.g = (char)RemapValClamped( flLifetimePercent, 0.0f, 1.0f, 30, 255 );
		}

		float flHeight = 50.0f;
		float flXPos = m_aTexts[i].vecPos.x;
		float flYPos = m_aTexts[i].vecPos.y - ( 1.0f - flLifetimePercent ) * flHeight;

		sf::Text newText( m_aTexts[i].text, m_Font );
		sf::FloatRect textBounds = newText.getLocalBounds();
		newText.setOrigin( textBounds.width / 2.0f, textBounds.height );
		newText.setPosition( flXPos, flYPos );
		newText.setFillColor( deltaColor );

		g_pGameLogic->GetWindow()->draw( newText );
	}
}
예제 #2
0
void RenderedImage::rayTraceResult(const PhysicalRay &ray, QRgb color)
{
    QMutexLocker locker(&m_mutex);
    /* Средневзвешенное цветов упершихся лучей с весами в интенсивность */
    QColor prevcolor(m_image.pixel(ray.startingX(), ray.startingY()));
    QColor deltaColor(color);
    QColor newcolor = QColor::fromRgbF(qMin(prevcolor.redF()+deltaColor.redF()*ray.intensity(), 1.0),
                                       qMin(prevcolor.greenF()+deltaColor.greenF()*ray.intensity(), 1.0),
                                       qMin(prevcolor.blueF()+deltaColor.blueF()*ray.intensity(), 1.0));
/*        qDebug() << "Point" << ray.startingX() << ray.startingY() << \
                "Switched from" << prevcolor.name() << "TO" << newcolor.name() << \
                "because of" << ray.intensity() << QColor(color).name();*/

    m_image.setPixel(ray.startingX(), ray.startingY(),
                     newcolor.rgb());
}