魔塔 游戏开发 2


---------------------------------Role.h---------------------------------

class MAN
{
public:
int nHP;
int nAttact;
int nDefense;
int nPosx,nPosy;
bool bKilled;
public:
MAN();
bool IsKilled();
void SetPosX(int xPos);
void SetPosY(int yPos);
};


class MONSTER
{
public:
int nLevel;
int nHP;
int nAttact;
int nDefense;
bool bKilled;
//int nPosx,nPosy;
public:
MONSTER();
void SetMonster(int nHP,int nLevel,int nAttact,int nDefense);
bool IsKilled();




};


struct POS
{
int xPos;
int yPos;
bool bIsMonster;
bool bIsWeapon;
};



#define MAN_U 0
#define MAN_D 50
#define MAN_L 100
#define MAN_R 150

---------------------------------------------------Role.cpp-----------------------------------------------------------------

#include "Role.h"




MAN::MAN()
{
nHP=100;
nAttact=10;
nDefense=0;
nPosx=0,nPosy=0;
bKilled=false;
}
bool MAN::IsKilled()
{
if(nHP<=0)
{
bKilled=true;
return true;
}
else
return false;
}
void MAN::SetPosX(int xPos)
{
nPosx=xPos;
}
void MAN::SetPosY(int yPos)
{
nPosy=yPos;
}
//===============Monster===================
MONSTER::MONSTER()
{
nHP=0;
nAttact=0;
nDefense=0;
nLevel=0;
bKilled=false;
}
void MONSTER::SetMonster(int HP, int Level, int Attact, int Defense)
{
nHP=HP;
nLevel=Level;
nAttact=Attact;
nDefense=Defense;
}


bool MONSTER::IsKilled()
{
if(nHP<=0)
{
bKilled=true;
return true;
}
else
return false;
}

你可能感兴趣的:(魔塔 游戏开发 2)