HealthBar.cpp

Go to the documentation of this file.
00001 /* 
00002  * File:   HealthBar.cpp
00003  * Author: chris
00004  * 
00005  * Created on April 29, 2013, 10:34 AM
00006  */
00007 
00008 #include "HealthBar.h"
00009 //test commit
00010 HealthBar::HealthBar(Ogre::ManualObject* mObj, float percent = 100.0f, bool startOnLeft = true):
00011 percent(percent), startOnLeft(startOnLeft), fullBar(new Rect(0, 20, Ogre::ColourValue(0,1,0),mObj)),
00012         emptyBar(new Rect(0, 20, Ogre::ColourValue(1,0,0),mObj))
00013 {
00014 }
00015 
00016 HealthBar::HealthBar(const HealthBar& orig)
00017 {
00018 }
00019 
00020 HealthBar::~HealthBar()
00021 {
00022 }
00023 
00024 void HealthBar::Draw(Ogre::Vector3 pos)
00025 {
00026     const float length = 200;
00027     const float edge = pos.x - (length / 2.0);
00028     //ClearVertices();
00029     fullBar->length = length * (percent / 100.0f);
00030     emptyBar->length = length - fullBar->length;
00031     //float fullStart = pos.x - length + (fullBar->length);
00032     //float emptyStart = fullStart + (fullBar->length / 2.0) + (emptyBar->length / 2.0);
00033     float fullStart = edge + (fullBar->length / 2.0);
00034     float emptyStart = fullStart + (fullBar->length / 2.0) + (emptyBar->length / 2.0);
00035     fullBar->Draw(Ogre::Vector3(fullStart, pos.y, pos.z));
00036     emptyBar->Draw(Ogre::Vector3(emptyStart, pos.y, pos.z));    
00037     
00038 }
00039 //if the mObj is shared between multiple healthbars, clear() resets them all
00040 void HealthBar::ClearVertices()
00041 {
00042     fullBar->ClearVertices();
00043     emptyBar->ClearVertices();
00044 }

Generated on Fri Dec 13 14:54:16 2013 for FastECSLent by  doxygen 1.5.4