HealthBar Library

HealthBar.cpp

Committer:
ll14c4p
Date:
2017-05-04
Revision:
1:9f2d307b3b99
Parent:
0:aa460a91bd33
Child:
3:824c16fb35e7

File content as of revision 1:9f2d307b3b99:

#include "HealthBar.h"

HealthBar::HealthBar()
{

}

HealthBar::~HealthBar()
{

}



void HealthBar::init(int HP)
{
    _HP = HP;
    
}

void HealthBar::MinusHP1(int HPLost1)
{
    _HPLost1 = HPLost1;
    }
    
void HealthBar::MinusHP2(int HPLost2)
{
    _HPLost2 = HPLost2;
    }

void HealthBar::draw(N5110 &lcd)
{   //printf("%d hp \n", _HP); //working
    //printf("%d hplost1 \n", _HPLost1); //Working
    //printf("%d hplost2 \n", _HPLost2);
    
    
    //Calculates Total HP by taking the initial HP value and subtracting the
    //HP lost variables which update each time an instance resulting in 
    //HP loss occurs.
    //HP Bar actively updates on screen depending on remaining HP.
    //When total hp is equal to zero, a variable is assigned the 1 value
    //which will cause the player to lose the game.
    
    TotalHP = _HP + _HPLost1 + _HPLost2;
    //printf("%d TotalHP \n", TotalHP);
    if(TotalHP == 8){
    lcd.drawLine(0,47,84,47,1); //Working
    }
    if(TotalHP == 7){
    lcd.drawLine(0,47,70,47,1); //Working
    }
    if(TotalHP == 6){
    lcd.drawLine(0,47,60,47,1); //Working
    }
    if(TotalHP == 5){
    lcd.drawLine(0,47,50,47,1); //Working
    }
    if(TotalHP == 4){
    lcd.drawLine(0,47,40,47,1); //Working
    }
    if(TotalHP == 3){
    lcd.drawLine(0,47,30,47,1); //Working
    }
    if(TotalHP == 2){
    lcd.drawLine(0,47,20,47,1); //Working
    }
    if(TotalHP == 1){
    lcd.drawLine(0,47,10,47,1); //Working
    }
    if(TotalHP == 0){
        ZeroHP = 1;
    }
    

}

void HealthBar::update() //To actively update the health bar.
{
    }