⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mapobject.h

📁 一个symbian 冒险游戏代码
💻 H
字号:
#ifndef _MAPOBJECT_H
#define _MAPOBJECT_H


#include "Def.h"
#include "stdint.h"
#include "FixVec2.h"
#include <lang/Object.h>


class Map;
class Surface;

namespace io {
	class InputStream;
	class OutputStream;}


class MapObject
{
public:
	enum Dir
	{
		DIR_0,
		DIR_45,
		DIR_90,
		DIR_135,
		DIR_180,
		DIR_225,
		DIR_270,
		DIR_315,
		DIR_COUNT
	};

	enum Side
	{
		SIDE_LEFT		= -1,
		SIDE_MIDDLE		= 0,
		SIDE_RIGHT		= 1
	};

	MapObject();
	explicit MapObject( const char* name );
	virtual ~MapObject();

	virtual void		update( Fix dt ) = 0;
	virtual void		draw( Surface& dst ) = 0;
	virtual void		damage( Fix hp, MapObject* enemy ) = 0;
	virtual void		disturb( MapObject* enemy ) = 0;
	virtual void		addItem( const char* name ) = 0;
	virtual void		removeItem( const char* name ) = 0;
	virtual bool		isInState( const char* statename ) = 0;
	virtual void		read( io::InputStream* in );
	virtual void		write( io::OutputStream* out );
	virtual FixVec2		blockRenderPositionReference() const;
	virtual FixVec2		blockRenderPositionExtreme() const;

	void		resetDrawn()	{m_isDrawn = false;}
	bool		isDrawn()		{return m_isDrawn;}

	void		setHitPoints( Fix hp );

	void		setSanity( Fix sanity );

	void		setName( const char* name );

	void		setPosition( const FixVec2& pos );

	void		setBlockPosition( const FixVec2& pos );

	void		setDirection( Dir dir );

	void		setSpeed( Fix speed );

	// called by the framework before update(). use restorePosition() to roll back
	void		storePosition();

	// see storePosition()
	void		restorePosition();

	// gets nearby objects, excl. this one
	int			getObjects( const FixVec2& pos, Fix maxdist, Fix maxanglecos, MapObject** objlist, int maxobjs );

	Dir			direction() const				{return (Dir)m_dir;}

	FixVec2		directionVector() const;

	// returns position in blocks
	FixVec2		blockPosition() const;

	// returns position in pixels
	const FixVec2&		position() const		{return m_pos;}

	const char*	name() const					{return m_name;}

	Fix			speed() const					{return m_speed;}

	Fix			hitPoints() const				{return m_hitpoints;}

	Fix			maxHitPoints() const			{return m_maxHitPoints;}

	Fix			sanity() const					{return m_sanity;}

	bool		isDead() const					{return m_hitpoints <= Fixf(0);}

	bool		isSkillSuccess( Fix level ) const;

	static Dir	getAngleAsDir( Fix degrees );

	static Dir	getATanAsDir( const FixVec2& v );

	static const char*	expandPath( const char* sz );

protected:
	friend class Map;

	int			MapObject_storeStart; //Stored data start
	Map*		m_map;
	FixVec2		m_pos;
	Fix			m_speed;
	Fix			m_hitpoints;
	Fix			m_maxHitPoints;
	Fix			m_sanity;
	bool		m_isDrawn;

private:
	FixVec2		m_prevPos;
	char		m_name[256];
	char		m_dir;
	int			MapObject_storeEnd; //Stored data end
};


#endif // _MAPOBJECT_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -