basegameentity.h
来自「这是刚才的一个系列 继续发 希望能帮到更多的编程爱好者」· C头文件 代码 · 共 59 行
H
59 行
#ifndef ENTITY_H
#define ENTITY_H
//------------------------------------------------------------------------
//
// Name: BaseGameEntity.h
//
// Desc: Base class for a game object
//
// Author: Mat Buckland 2002 (fup@ai-junkie.com)
//
//------------------------------------------------------------------------
#include <string>
#include "messaging/Telegram.h"
class BaseGameEntity
{
private:
//every entity must have a unique identifying number
int m_ID;
//this is the next valid ID. Each time a BaseGameEntity is instantiated
//this value is updated
static int m_iNextValidID;
//this must be called within the constructor to make sure the ID is set
//correctly. It verifies that the value passed to the method is greater
//or equal to the next valid ID, before setting the ID and incrementing
//the next valid ID
void SetID(int val);
public:
BaseGameEntity(int id)
{
SetID(id);
}
virtual ~BaseGameEntity(){}
//all entities must implement an update function
virtual void Update()=0;
//all entities can communicate using messages. They are sent
//using the MessageDispatcher singleton class
virtual bool HandleMessage(const Telegram& msg)=0;
int ID()const{return m_ID;}
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?