All pastes #39651 Raw Edit

Someone

public text v1 · immutable
#39651 ·published 2006-02-02 19:21 UTC
rendered paste body
class 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;
	}

}