void FireTrap::Render(void) { SGD::GraphicsManager* pGraphics = SGD::GraphicsManager::GetInstance(); SGD::Point point = { m_ptPosition.x - GameplayState::GetInstance()->GetWorldCam().x, m_ptPosition.y - GameplayState::GetInstance()->GetWorldCam().y }; if (GameplayState::GetInstance()->GetDebugState()) { SGD::Rectangle rec = GetRect(); rec.Offset(-GameplayState::GetInstance()->GetWorldCam().x, -GameplayState::GetInstance()->GetWorldCam().y); pGraphics->DrawRectangle(rec, SGD::Color(0, 0, 255)); } // - Temp Code till we have sprites. //SGD::Rectangle rec = GetRect(); // rec.Offset( -GameplayState::GetInstance()->GetWorldCam().x, -GameplayState::GetInstance()->GetWorldCam().y ); // - Collision Rectangle pGraphics->DrawTexture(m_hImage, point); if (m_bStartTimer) m_pParticle.RenderPoint(point); //pGraphics->DrawRectangle( rec, SGD::Color( 255, 0, 0 ) ); }
void Tower::Render() { SGD::GraphicsManager* pGraphics = SGD::GraphicsManager::GetInstance(); SGD::Rectangle rect = GetRect(); rect.left -= Camera::x; rect.right -= Camera::x; rect.top -= Camera::y; rect.bottom -= Camera::y; Game* pGame = Game::GetInstance(); // -- Debugging -- if (pGame->IsShowingRects()) pGraphics->DrawRectangle(rect, SGD::Color(128, 0, 0, 255)); if (m_bSelected) pGraphics->DrawRectangle(rect, SGD::Color(0, 0, 0, 0), SGD::Color(255, 255, 0), 2); }
void HUD::Render(void) { SGD::GraphicsManager* pGraphics = SGD::GraphicsManager::GetInstance(); const BitmapFont* pFont = Game::GetInstance()->GetFont(); // Draw the HUD image float screenheight = Game::GetInstance()->GetScreenHeight(); //pGraphics->DrawTextureSection(m_hBackgroundImage, { 1.5f, screenheight - 112.0f }, SGD::Rectangle(4.0f, 694.0f, 708.0f, 806.0f)); //pGraphics->DrawTexture(m_hBackgroundImage, { 1.5f, screenheight - 112.0f }); // draw health bars SGD::Rectangle currhealth = { 0, 0, m_pPlayer->GetCurrHealth() / m_pPlayer->GetMaxHealth() * 200, 35 }; SGD::Rectangle maxhealth = { 0, 0, 200, 35 }; pGraphics->DrawRectangle(maxhealth, { 0, 0, 255 }); SGD::Color healthcolor; if (m_pPlayer->GetCurrHealth() == m_pPlayer->GetMaxHealth()) // 100 -> Green healthcolor = { 0, 255, 0 }; else if (m_pPlayer->GetCurrHealth() <= m_pPlayer->GetMaxHealth() * 0.5F) // 0 - 25 -> Red healthcolor = { 255, 0, 0 }; else // 25 - 99 -> yellow healthcolor = { 255, 255, 0 }; pGraphics->DrawRectangle(currhealth, healthcolor); // draw health as a string int hp = static_cast<int>(m_pPlayer->GetCurrHealth()); stringstream health; health << "HP: " << hp; pFont->Draw(health.str().c_str(), { 0, 0 }, 1.0f, { 255, 0, 255 }); }
void QuickTimeState::HandleTutorial() { if( GameplayState::GetInstance()->GetCurrentLevel() == 0 ) { SGD::GraphicsManager* pGraphics = SGD::GraphicsManager::GetInstance(); BitmapFontManager *pFont = BitmapFontManager::GetInstance(); SGD::Point ptWorldCam = GameplayState::GetInstance()->GetWorldCam(); SGD::Point heroPosition; SGD::Point portraitPosition; // - Location of the Dialog Box at the bottom of the screen. SGD::Rectangle DialogBoxOne; DialogBoxOne.left = 25; DialogBoxOne.top = Game::GetInstance()->GetScreenHeight() - 105; DialogBoxOne.right = Game::GetInstance()->GetScreenWidth() - 25; DialogBoxOne.bottom = Game::GetInstance()->GetScreenHeight() - 5; // - Location to print the strings within the dialog Box SGD::Point TextPositionOne; SGD::Point TextPositionTwo; TextPositionOne.x = DialogBoxOne.left + 40; TextPositionOne.y = DialogBoxOne.top + 20; TextPositionTwo.x = DialogBoxOne.left + 20; TextPositionTwo.y = DialogBoxOne.top + 50; portraitPosition.x = DialogBoxOne.left - 10; portraitPosition.y = DialogBoxOne.top - 30; if( Game::GetInstance()->GetIcelandic() ) { TextPositionOne.x = DialogBoxOne.left + 50; TextPositionTwo.x = DialogBoxOne.left + 50; } else { TextPositionOne.x = DialogBoxOne.left + 100; TextPositionTwo.x = DialogBoxOne.left + 100; } heroPosition = { (float)( ( 3 * 32 ) - ptWorldCam.x ), (float)( ( 8 * 32 ) - ptWorldCam.y ) }; pGraphics->DrawRectangle( DialogBoxOne, SGD::Color( 220, 215, 143 ), SGD::Color( 0, 0, 0 ) ); pGraphics->DrawTexture( GameplayState::GetInstance()->GetPortrait(), portraitPosition ); pFont->Render( "Dialog", Game::GetInstance()->GetString( 9, 7 ).c_str(), TextPositionOne, .7f, SGD::Color( 0, 0, 0 ) ); pFont->Render( "Dialog", Game::GetInstance()->GetString( 9, 8 ).c_str(), TextPositionTwo, .7f, SGD::Color( 0, 0, 0 ) ); } }
// Render /*virtual*/ void PauseState::Render(void) { float width = Game::GetInstance()->GetScreenWidth(); float height = Game::GetInstance()->GetScreenHeight(); SGD::GraphicsManager * pGraphics = SGD::GraphicsManager::GetInstance(); if (HTPGameState::GetInstance()->GetChoiceScreen() == false) HTPGameState::GetInstance()->Render(); else GameplayState::GetInstance()->Render(); pGraphics->DrawRectangle({ 0, 0, Game::GetInstance()->GetScreenWidth(), Game::GetInstance()->GetScreenHeight() }, { 210, 0, 0, 0 }); // Use the game's font const BitmapFont* pFont = Game::GetInstance()->GetFont(); // Align text based on window width float scale = 1.25f; // Display the game title centered at 4x scale pFont->Draw("PAUSED", { (width - (9 * 32 * 3.0f)) / 2, (26.0F * 3.0F) }, 3.0f, { 255, 255, 255 }); if (m_nCursor == 0) { pFont->Draw("Resume", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 100.0f }, scale, { 255,255,255 }); pFont->Draw("Controls", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 200.0f }, scale, { 255, 0, 0 }); pFont->Draw("Options", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 300.0f }, scale, { 255, 0, 0 }); if (HTPGameState::GetInstance()->GetChoiceScreen() == false) pFont->Draw("Start Game", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 400.0f }, scale, { 255, 0, 0 }); else pFont->Draw("Quit to Menu", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 400.0f }, scale, { 255, 0, 0 }); } else if (m_nCursor == 1) { pFont->Draw("Resume", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 100.0f }, scale, { 255, 0, 0 }); pFont->Draw("Controls", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 200.0f }, scale, { 255, 255, 255 }); pFont->Draw("Options", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 300.0f }, scale, { 255, 0, 0 }); if (HTPGameState::GetInstance()->GetChoiceScreen() == false) pFont->Draw("Start Game", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 400.0f }, scale, { 255, 0, 0 }); else pFont->Draw("Quit to Menu", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 400.0f }, scale, { 255, 0, 0 }); } else if (m_nCursor == 2) { pFont->Draw("Resume", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 100.0f }, scale, { 255, 0, 0 }); pFont->Draw("Controls", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 200.0f }, scale, { 255, 0, 0 }); pFont->Draw("Options", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 300.0f }, scale, { 255, 255, 255 }); if (HTPGameState::GetInstance()->GetChoiceScreen() == false) pFont->Draw("Start Game", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 400.0f }, scale, { 255, 0, 0 }); else pFont->Draw("Quit to Menu", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 400.0f }, scale, { 255, 0, 0 }); } else if (m_nCursor == 3) { pFont->Draw("Resume", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 100.0f }, scale, { 255, 0, 0 }); pFont->Draw("Controls", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 200.0f }, scale, { 255, 0, 0 }); pFont->Draw("Options", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 300.0f }, scale, { 255, 0, 0 }); if (HTPGameState::GetInstance()->GetChoiceScreen() == false) pFont->Draw("Start Game", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 400.0f }, scale, { 255, 255, 255 }); else pFont->Draw("Quit to Menu", { (width*0.25f - (2 * 32 * scale)) / 2, (height * 0.25F) + 400.0f }, scale, { 255, 255, 255 }); } }
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 }); // } //} }