Numeric Energy HUD
by Josh Moore · 04/11/2006 (2:01 pm) · 4 comments
I made this to display ShapeBase energy as a number so I can use it as ammo for my tanks and turrets. Having a little bar that shows your current energy out of the max just wouldn't work. I'm resourcing it as I'm sure a few people out there will want to do the same thing.
Create a new .cc file with
Enjoy!
Create a new .cc file with
//-----------------------------------------------------------------------------
// Numeric Energy Hud - By Josh Moore
//-----------------------------------------------------------------------------
// This takes a client's control object's energy and displays it as a number
#include "dgl/dgl.h"
#include "gui/core/guiControl.h"
#include "game/gameConnection.h"
#include "game/shapeBase.h"
//-----------------------------------------------------------------
class NumericEnergyHud : public GuiControl
{
typedef GuiControl Parent;
public:
NumericEnergyHud();
void onRender(Point2I, const RectI &rect);
DECLARE_CONOBJECT(NumericEnergyHud);
};
//-----------------------------------------------------------------
IMPLEMENT_CONOBJECT(NumericEnergyHud);
NumericEnergyHud::NumericEnergyHud()
{
}
//-----------------------------------------------------------------
void NumericEnergyHud::onRender(Point2I offset, const RectI &updateRect)
{
GameConnection* conn = GameConnection::getConnectionToServer();
if(!conn) return;
ShapeBase* control = conn->getControlObject();
if(!control) return;
char display[128];
dSprintf(display, 128, "%2.0f[[60c20c3b180d4]]", mFloor(control->getEnergyLevel()));
dglSetBitmapModulation(mProfile->mFontColor);
renderJustifiedText(offset, mBounds.extent, display);
dglClearBitmapModulation();
}Enjoy!
About the author

Torque Owner Chris Byars
Ion Productions