rendered paste bodyclass Building
{
public:
Building(char name[18], Mesh mesh, int maxhp);
int UpdateHP(int change);
char myName[18];
Vector myPosition;
Mesh myMesh;
private:
int myMaxHP
int myHP
};
//EOF
#include "Building.h"
Building::Building(char name[18], Mesh mesh, int maxhp)
{
myName = name;
myMesh = mesh;
myMaxHP = maxhp;
myHP = maxhp;
}
//pass negative numbers to subtract hp
int Building::UpdateHP(int change)
{
int result;
result = myHP + change;
if (result > myMaxHP) // cant heal past the maxHP
{
myHP = myMaxHP;
return 1
}
if(result <= 0)
{
myHP = 0;
return 0;
}
else
{
myHP = result;
return 1;
}
}