Ejemplo n.º 1
0
	Color StyleData::calculateColor(const ColorData& mColorData) const
	{
		Color color{mColorData.color};

		if(mColorData.dynamic)
		{
			const auto& dynamicColor(getColorFromHue((currentHue + mColorData.hueShift) / 360.f));

			if(!mColorData.main)
			{
				if(mColorData.dynamicOffset)
				{
					assert(mColorData.offset != 0);

					color.r += dynamicColor.r / mColorData.offset;
					color.g += dynamicColor.g / mColorData.offset;
					color.b += dynamicColor.b / mColorData.offset;
					color.a += dynamicColor.a;
				}
				else color = getColorDarkened(dynamicColor, mColorData.dynamicDarkness);
			}
			else color = dynamicColor;
		}

		const auto& pulse(mColorData.pulse);
		return Color(getClamped(color.r + pulse.r * pulseFactor, 0.f, 255.f),
					 getClamped(color.g + pulse.g * pulseFactor, 0.f, 255.f),
					 getClamped(color.b + pulse.b * pulseFactor, 0.f, 255.f),
					 getClamped(color.a + pulse.a * pulseFactor, 0.f, 255.f));
	}
Ejemplo n.º 2
0
	void CPlayer::draw()
	{
		drawPivot();
		const auto& isDrawing3D(hexagonGame.getStatus().drawing3D);

		if(!isDrawing3D && deadEffectTimer.isRunning()) drawDeathEffect();

		Color colorMain{!dead || isDrawing3D ? hexagonGame.getColorMain() : getColorFromHue(hue / 255.f)};

		pLeft = getOrbitFromDegrees(pos, angle - 100, size + 3);
		pRight = getOrbitFromDegrees(pos, angle + 100, size + 3);

		vertices[0].position = getOrbitFromDegrees(pos, angle, size);
		vertices[1].position = pLeft;
		vertices[2].position = pRight;

		if(!swapTimer.isRunning() && !isDrawing3D) colorMain = getColorFromHue((swapBlinkTimer.getCurrent() * 15) / 255.f);
		for(int i{0}; i < 3; ++i) vertices[i].color = colorMain;

		hexagonGame.render(vertices);
	}
Ejemplo n.º 3
0
	inline void CPlayer::drawPivot()
	{
		float thickness{5};

		Color colorMain{hgPtr->getColorMain()};
		Color colorB{hgPtr->getColorB()};
		
		float div {360.f / hgPtr->getSides()};
		float radius {hgPtr->getRadius() * 0.75f};
		Vector2f pivotPos{startPos};

		if(isDead)
		{
			pivotPos = pos;			
			colorMain = getColorFromHue((360 - hue) / 255.0f);
			if(hue++ > 360) hue = 0;
			radius = hue / 8;
			thickness = hue / 20;
		}

		VertexArray vertices2 {PrimitiveType::Quads, 4};
		VertexArray vertices3 {PrimitiveType::Triangles, 3};

		for(int i{0}; i < hgPtr->getSides(); i++)
		{
			float angle { div * i };

			Vector2f p1{getOrbit(pivotPos, angle - div * 0.5f, radius)};
			Vector2f p2{getOrbit(pivotPos, angle + div * 0.5f, radius)};
			Vector2f p3{getOrbit(pivotPos, angle + div * 0.5f, radius + thickness)};
			Vector2f p4{getOrbit(pivotPos, angle - div * 0.5f, radius + thickness)};
			
			vertices2.append(Vertex{p1, colorMain});
			vertices2.append(Vertex{p2, colorMain});
			vertices2.append(Vertex{p3, colorMain});
			vertices2.append(Vertex{p4, colorMain});

			vertices3.append(Vertex{p1, colorB});
			vertices3.append(Vertex{p2, colorB});
			vertices3.append(Vertex{pivotPos, colorB});
		}
		
		if(!isDead) hgPtr->drawOnTexture(vertices3);
		hgPtr->drawOnTexture(vertices2);
	}
Ejemplo n.º 4
0
	void CPlayer::draw()
	{
		drawPivot();

		Color colorMain{hgPtr->getColorMain()};

		if(isDead) colorMain = getColorFromHue(hue / 255.0f);

		pLeft = getOrbit(pos, angle - 100, size + 3);
		pRight = getOrbit(pos, angle + 100, size + 3);

		vertices[0].position = getOrbit(pos, angle, size);
		vertices[1].position = pLeft;
		vertices[2].position = pRight;

		vertices[0].color = colorMain;
		vertices[1].color = colorMain;
		vertices[2].color = colorMain;

		hgPtr->drawOnTexture(vertices);
	}
Ejemplo n.º 5
0
	void CPlayer::drawDeathEffect()
	{
		float div{360.f / hexagonGame.getSides() * 0.5f}, radius{hue / 8}, thickness{hue / 20};
		Color colorMain{getColorFromHue((360 - hue) / 255.f)};
		VertexArray verticesDeath{PrimitiveType::Quads, 4};
		if(hue++ > 360) hue = 0;

		for(auto i(0u); i < hexagonGame.getSides(); ++i)
		{
			float sAngle{div * 2.f * i};

			Vec2f p1{getOrbitFromDegrees(pos, sAngle - div, radius)};
			Vec2f p2{getOrbitFromDegrees(pos, sAngle + div, radius)};
			Vec2f p3{getOrbitFromDegrees(pos, sAngle + div, radius + thickness)};
			Vec2f p4{getOrbitFromDegrees(pos, sAngle - div, radius + thickness)};

			verticesDeath.append({p1, colorMain});
			verticesDeath.append({p2, colorMain});
			verticesDeath.append({p3, colorMain});
			verticesDeath.append({p4, colorMain});
		}

		hexagonGame.render(verticesDeath);
	}
Ejemplo n.º 6
0
	void CPlayer::drawDeathEffect()
	{
		float div{360.f / hexagonGame.getSides() * 0.5f}, radius{hue / 8}, thickness{hue / 20};
		Color colorMain{getColorFromHue((360 - hue) / 255.f)};
		ssvs::VertexVector<sf::PrimitiveType::Quads> verticesDeath(4);
		if(hue++ > 360) hue = 0;

		for(auto i(0u); i < hexagonGame.getSides(); ++i)
		{
			float sAngle{div * 2.f * i};

			Vec2f p1{getOrbitFromDeg(pos, sAngle - div, radius)};
			Vec2f p2{getOrbitFromDeg(pos, sAngle + div, radius)};
			Vec2f p3{getOrbitFromDeg(pos, sAngle + div, radius + thickness)};
			Vec2f p4{getOrbitFromDeg(pos, sAngle - div, radius + thickness)};

			verticesDeath.emplace_back(p1, colorMain);
			verticesDeath.emplace_back(p2, colorMain);
			verticesDeath.emplace_back(p3, colorMain);
			verticesDeath.emplace_back(p4, colorMain);
		}

		hexagonGame.render(verticesDeath);
	}
Ejemplo n.º 7
0
	void CPlayer::draw()
	{
		drawPivot();
		if(dead && !hexagonGame.getStatus().drawing3D) drawDeathEffect();

		Color colorMain{!dead || hexagonGame.getStatus().drawing3D ? hexagonGame.getColorMain() : getColorFromHue(hue / 255.0f)};

		pLeft = getOrbitFromDegrees(pos, angle - 100, size + 3);
		pRight = getOrbitFromDegrees(pos, angle + 100, size + 3);

		vertices[0].position = getOrbitFromDegrees(pos, angle, size);
		vertices[1].position = pLeft;
		vertices[2].position = pRight;

		for(int i{0}; i < 3; ++i) vertices[i].color = colorMain;

		hexagonGame.render(vertices);
	}