Пример #1
0
void AnimationManager::Render(AnimationTimestamp& ants, float x, float y, float rotation, SGD::Vector center, SGD::Color col)
{
	SGD::GraphicsManager* g = SGD::GraphicsManager::GetInstance();
	//g->DrawLine({ (float)x, (float)y }, { (float)x + 2, (float)y + 2 });

	x -= m_mSprites[ants.m_nCurrAnimation]->GetFrame(ants.m_nCurrFrame).GetAnchorPoint().x;
	y -= m_mSprites[ants.m_nCurrAnimation]->GetFrame(ants.m_nCurrFrame).GetAnchorPoint().y;

	SGD::Rectangle r = m_mSprites[ants.m_nCurrAnimation]->GetFrame(ants.m_nCurrFrame).GetFrameRect();

	// Getting the specific frame
	//r.right += r.left;
	//r.bottom += r.top;


	g->DrawTextureSection(m_mSprites[ants.m_nCurrAnimation]->GetImage(),
	{ (float)x, (float)y },
	r, rotation, center, col);

	SGD::Rectangle dr = r;
	dr.top += y;
	dr.bottom += y;
	dr.left += x;
	dr.right += x;

	//g->DrawRectangle(dr, { 128, 255, 255, 0 });

}
void const OptionsState::Render()
{
	
	SGD::GraphicsManager * graphics = SGD::GraphicsManager::GetInstance();
	graphics->DrawTextureSection(background, { 0.0, 0.0 }, { 0.0f, 0.0f, 800.0f, 600.0f });
	GameData::GetInstance()->GetFont()->DrawString("Options Menu", 60.0f, 40.0f, { 0, 0, 0 }, 2.0f);
	SGD::GraphicsManager::GetInstance()->DrawTextureSection(button, { 45.0f, 95.0f }, { 15.0f, 5.0f, 240.0f, 70.0f });
	SGD::GraphicsManager::GetInstance()->DrawTextureSection(button, { 45.0f, 175.0f }, { 15.0f, 5.0f, 240.0f, 70.0f });
	SGD::GraphicsManager::GetInstance()->DrawTextureSection(button, { 45.0f, 255.0f }, { 15.0f, 5.0f, 240.0f, 70.0f });
	SGD::GraphicsManager::GetInstance()->DrawTextureSection(button, { 45.0f, 335.0f }, { 15.0f, 5.0f, 240.0f, 70.0f });
	SGD::GraphicsManager::GetInstance()->DrawTextureSection(button, { 45.0f, 415.0f }, { 15.0f, 5.0f, 240.0f, 70.0f });

	graphics->DrawTextureSection(cursor, { 10.0f, 95.0f + (menuindex * 80) }, { 0, 0, 238, 73 });

	GameData::GetInstance()->GetFont()->DrawString("Language:", 70.0f, 120.0f, { 155, 155, 155 }, 1.5f);
	if (GameData::GetInstance()->GetFont()->IsSpanish())
		GameData::GetInstance()->GetFont()->DrawString("Spanish",150.0f, 125.0f, { 0,0,0 });
	else
		GameData::GetInstance()->GetFont()->DrawString("English", 175.0f, 125.0f, { 0,0,0 });

	GameData::GetInstance()->GetFont()->DrawString("Music Volume:", 70.0f, 200.0f, { 155, 155, 155 }, 1.5f);
	std::ostringstream mout;
	mout << GameData::GetInstance()->GetMusicVolume();
	GameData::GetInstance()->GetFont()->DrawString(mout.str(), 220.0f, 205.0f, { 0,0,0 });
	GameData::GetInstance()->GetFont()->DrawString("Effect Volume:", 70.0f, 280.0f, { 155, 155, 155 }, 1.5f);
	std::ostringstream eout;
	eout << GameData::GetInstance()->GetEffectVolume();
	GameData::GetInstance()->GetFont()->DrawString(eout.str(), 220.0f, 285.0f, { 0,0,0 });

	GameData::GetInstance()->GetFont()->DrawString("FullScreen:", 70.0f, 360.0f, { 155, 155, 155 }, 1.5f);
	if (GameData::GetInstance()->GetWindowed())
		GameData::GetInstance()->GetFont()->DrawString("Off", 200.0f, 360.0f, { 0,0,0 });
	else
		GameData::GetInstance()->GetFont()->DrawString("On", 200.0f, 360.0f, { 0,0,0 });

	GameData::GetInstance()->GetFont()->DrawString("Exit", 70.0f, 440.0f, { 155, 155, 155 }, 1.5f);


	//graphics->DrawRectangle({ 35.0f, 100.0f + (menuindex * 50), 45.0f, 110.0f + (menuindex * 50) }, { 155, 0, 155 }, { 155, 155, 155 });
}
Пример #3
0
void WeaponManager::Render()
{
	SGD::GraphicsManager * pGraphics = SGD::GraphicsManager::GetInstance();

	const BitmapFont * bFont = Game::GetInstance()->GetFont();

	SGD::Rectangle equipRect = { Game::GetInstance()->GetScreenWidth() - 343.0f, Game::GetInstance()->GetScreenHeight() - 135.0f, Game::GetInstance()->GetScreenWidth() - 60, Game::GetInstance()->GetScreenHeight() - 10 };

	int widthOffset = -10;
	int heightOffset = -15;
	float sWidth = Game::GetInstance()->GetScreenWidth() - 303;
	float sHeight = Game::GetInstance()->GetScreenHeight() - 195;

	SGD::Rectangle unEquip;

	//for (unsigned int j = 0; j < 5; j++)
	//{
	//	//unEquip = { sWidth - size, sHeight - 75, sWidth + size*j + size, sHeight };
	//	//pGraphics->DrawRectangle(unEquip, { 255, 255, 255 }, { 0, 0, 255 });

	//	//if (m_vWeapons[equipIndex]->GetObtained() == false)
	//	//{
	//	//	pGraphics->DrawRectangle({ sWidth + size*j, sHeight - size, sWidth + size*j + size, sHeight }, { 175, 0, 0, 0 });
	//	//}
	//}

	int index = 0;

	for (unsigned int j = 0; j < 5; j++)
	{
		index = j;
		
		for (int i = equipIndex; i > -1; i--)
		{
			//unEquip = { sWidth + widthOffset * j, sHeight - heightOffset * j, Game::GetInstance()->GetScreenWidth() - 10 - widthOffset * j, Game::GetInstance()->GetScreenHeight() - 10 + widthOffset*j};
			//pGraphics->DrawRectangle(unEquip, { 255, 255, 255 }, { 0, 0, 255 });

			if (m_vWeapons[i]->GetObtained() == true && m_vWeapons[i]->GetEquipped() == true)
			{
				SGD::Rectangle imageRect = m_vWeapons[i]->GetRenderRect();				

				if (m_vWeapons[i]->GetGunType() == m_vWeapons[curIndex]->GetGunType())
				{
					//pGraphics->DrawTextureSection(m_hHudWpn, { sWidth + widthOffset*j, sHeight - heightOffset * j },
					//	imageRect, {}, {}, {}, { 1.0f, 1.0f });
			
					//index--;
					//j--;

					if (index < 0)
					{
						index = 0;
					}

					equipRect = { sWidth + widthOffset*index, sHeight - heightOffset * index, sWidth + 282 + (widthOffset * index), sHeight + 125 - (heightOffset * index)  };
				}

				else
				{
					pGraphics->DrawRectangle({ sWidth + widthOffset*index, sHeight - heightOffset * index, sWidth + 282 + (widthOffset * index), sHeight + 125 - (heightOffset * index) }, { 255, 255, 255 }, { 0, 0, 255 },2);
					pGraphics->DrawTextureSection(m_hHudWpn, { sWidth + widthOffset*index, sHeight - heightOffset * index },
						imageRect, {}, {}, {}, { 1.0f, 1.0f });
					pGraphics->DrawRectangle({ (sWidth + widthOffset*index) - 2, (sHeight - heightOffset * index) - 2, (sWidth + 282 + (widthOffset * index)) + 2, (sHeight + 125 - (heightOffset * index)) + 2 }, { 175, 0, 0, 0 });
				}

				equipIndex--;
				break;
			}


			equipIndex--;
		}

	}

	pGraphics->DrawRectangle(equipRect, { 255, 255, 255 }, { 0, 0, 255 });

	pGraphics->DrawTextureSection(m_hHudWpn, { equipRect.left, equipRect.top },
		m_vWeapons[curIndex]->GetRenderRect(), {}, {}, {}, { 1.0, 1.0f });

	for (unsigned int i = 0; i < m_vWeapons.size(); i++)
	{
		if (m_vWeapons[curIndex]->GetGunType() == m_vWeapons[i]->GetGunType() && m_vWeapons[curIndex]->GetEquipped() == true)
		{


			stringstream magSize;
			magSize << m_vWeapons[curIndex]->GetCurrAmmo() << "|";

			SGD::Point magPos = { equipRect.left + 10, equipRect.bottom - 30 };
			SGD::Point ammoPos = { equipRect.left + 71, equipRect.bottom - 30 };

			if (m_vWeapons[curIndex]->GetCurrAmmo() < 10)
			{
				magPos.x = equipRect.left + 28;
			}

			bFont->Draw(magSize.str().c_str(), magPos, 1.0f, { 0, 0, 0 });

			stringstream ammoCap;
			ammoCap << m_vWeapons[curIndex]->GetTotalAmmo();

			if (m_vWeapons[curIndex]->GetTotalAmmo() < 10)
			{
				ammoPos.x = equipRect.left + 58;
			}

			else if (m_vWeapons[curIndex]->GetTotalAmmo() < 100)
			{
				ammoPos.x = equipRect.left + 68;
			}

			else
			{
				ammoPos.x = equipRect.left + 71;
			}

			if (m_vWeapons[curIndex]->GetType() == PISTOL)
			{
				bFont->Draw("INF", ammoPos, 1.0f, { 0, 0, 0 });
			}

			else
				bFont->Draw(ammoCap.str().c_str(), ammoPos, 1.0f, { 0, 0, 0 });

			//if (m_vWeapons[curIndex]->GetCurrAmmo() == 0 && m_vWeapons[curIndex]->GetTotalAmmo() > 0)
			//{
			//	//bFont->Draw("RELOADING", { Game::GetInstance()->GetScreenWidth() - 328, Game::GetInstance()->GetScreenHeight() - 130 }, 1.5f, { 200, 0, 0 });
			//}
			if (m_vWeapons[curIndex]->GetReloadTimer().GetTime() > 0 && m_vWeapons[curIndex]->GetTotalAmmo() > 0)
			{
				bFont->Draw("RELOADING", { equipRect.left + 5, equipRect.top + 5 }, 1.5f, { 200, 0, 0 });
				//bFont->Draw("RELOADING", { (Game::GetInstance()->GetScreenWidth() * 0.5f) - 100.0f, (Game::GetInstance()->GetScreenHeight() * 0.5f) - 70.0f }, 1.5f, { 200, 0, 0 });
				//bFont->Draw("RELOADING", { (Game::GetInstance()->GetScreenWidth() * 0.5f) - 100.0f, (Game::GetInstance()->GetScreenHeight() * 0.5f) + 30.0f }, 1.5f, { 200, 0, 0 });
			}
			else if (m_vWeapons[curIndex]->GetTotalAmmo() == 0 && m_vWeapons[curIndex]->GetCurrAmmo() <= 0)
			{
				bFont->Draw("OUT OF AMMO", { equipRect.left + 5, equipRect.top + 5 }, .75f, { 200, 0, 0 });
			//bFont->Draw("OUT OF AMMO", { (Game::GetInstance()->GetScreenWidth() * 0.5f) - 100.0f, (Game::GetInstance()->GetScreenHeight() * 0.5f) + 30.0f }, 1.5f, { 200, 0, 0 });
			}


		}
	}

	equipIndex = m_vWeapons.size() - 1;

	//for (unsigned int i = 0; i < 5; i++)
	//{
	//	for (unsigned int j = 0; j < m_vWeapons.size(); j++)
	//	{
	//		SGD::Rectangle unEquip = { sWidth + size*i, sHeight - 75, sWidth + size*i + size, sHeight };

	//		stringstream drawIndex;
	//		drawIndex << i + 1;

	//		bFont->Draw(drawIndex.str().c_str(), { unEquip.left + 1, unEquip.top - 5 }, .5f, { 150, 155, 155 });
	//	}
	//}


}