Show HUD.cpp syntax highlighted
/**
**************************************************************************************
*Palisma - Secrets of the Illuminati is an open-source 2D RPG *
*Copyright (C) 2006, Tony Sparks *
* *
*This library is free software; you can redistribute it and/or *
*modify it under the terms of the GNU Lesser General Public *
*License as published by the Free Software Foundation; either *
*version 2.1 of the License, or (at your option) any later version. *
* *
*This library is distributed in the hope that it will be useful, *
*but WITHOUT ANY WARRANTY; without even the implied warranty of *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
*Lesser General Public License for more details. *
* *
*You should have received a copy of the GNU Lesser General Public *
*License along with this library; if not, write to the Free Software *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
**************************************************************************************
*/
#include "StdAfx.h"
#include "HUD.h"
#include "entitymanager.h"
#include "../kernel.h"
extern Kernel* g_kernel;
HUD::HUD(Player* p)
{
m_player = p;
m_debugMode = true;
m_showInventory = false;
m_show = true;
}
HUD::HUD(void)
{
m_player = NULL;
m_debugMode = true;
m_showInventory = false;
m_show = true;
}
HUD::~HUD(void)
{
}
/** Draw the Players inventory */
void HUD::DrawInventory(IRender* r)
{
// TEMP
r->DrawString( 0, 400, m_player->m_weaponInventory.CurrentItem()->GetName().c_str() );
}
/** Draw the HUD */
void HUD::DrawHUD(IRender* r)
{
if ( m_debugMode )
{
DrawFPS( r );
DrawResCount( r );
}
if ( m_show && m_player )
{
DrawInventory( r );
}
}
/** Draw Health */
void HUD::DrawHealth(IRender* r)
{
}
/** Draw Gold coins amount */
void HUD::DrawCoins(IRender* r)
{
}
/*--------------------------
Debug info
---------------------------*/
/** Draw FPS counter */
void HUD::DrawFPS(IRender* r)
{
r->SetColor(1, 1, 1 );
float fps = 1.0f / ( g_kernel->GetFrameTime()/1000.0f );
r->DrawString(0,0, "FPS: %6.2f", fps );
}
/** Draw Active Entities count*/
void HUD::DrawResCount(IRender* r)
{
r->SetColor(1, 1, 1 );
r->DrawString( 120, 0, "Entities: %4i", EntityManager::GetInstance()->Count() );
r->DrawString( 240, 0, "Textures: %4i", g_kernel->GetResource()->Textures() );
r->DrawString( 360, 0, "Sounds: %4i", g_kernel->GetResource()->Sounds() );
int height = g_kernel->GetCvars()->GetFloatValue("v_height");
r->DrawString( 5, height-20, ("CurrentGameState: " + g_kernel->GetGame()->GetCurrentState()->GetName()).c_str() );
}
See more files for this project here