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

📄 mapinfo.h

📁 Visual C++ 游戏开发与设计实例 源代码(所有)
💻 H
字号:

#ifndef _ASIDER_TANK_ALPHA3_MAPINFO_H_
#define _ASIDER_TANK_ALPHA3_MAPINFO_H_

#include "object.h"
#include "resinfo.h"

enum WidthType{ WIDTH_32, WIDTH_16 };
//-----------------------------------------------------------------------------
// Classes defined in this header file 
//-----------------------------------------------------------------------------
class	CMapInfo;



//-----------------------------------------------------------------------------
// Default values of map file 
//-----------------------------------------------------------------------------
#define GAME_MAP_FILE_IDENTITY		19801227
#define GAME_MAP_VER_1_2_0			0x01020000		// map version 1.2.0
#define DEFAULT_CX_BLOCKS			21
#define DEFAULT_CY_BLOCKS			21
#define DEFAULT_BLOCKS				441


//-----------------------------------------------------------------------------
// Map file header format, also the structures involved
//-----------------------------------------------------------------------------
typedef struct tagFILEHAEDER
{
	DWORD	dwFileID;			// file info
	DWORD	dwVersion;
	DWORD	dwModifiedTime;
	char	szAuthor[20];
	char	szComment[80];
	DWORD	dwDataOffsite;		// start address of posbase

	DWORD	dwTreasure;			// treasure info
	int		nTimePersist;
	BOOL	bTimeRegular;
	int		nInterval;
	int		nMaxInter;
	int		nMinInter;

	int		nUnion;				// player info
	int		nTeam;			
	int		nComputer;

	int		nWidth;				// map info
	int		nHeight;
	int		nSingleSize;
	int		nBlocks;
	int		nNumOfLands;
	int		iaTotal[10];

//	POINT		*posBase;		// tanks info
//	TANKINFO	*infoTank;			
//	BLOCK		*pBlocks;		// blocks info
}FILEHEADER, * LPFILEHEADER;


typedef struct tagTankInfo		// for compatibility
{
	int		nUnion;						
	int		nTeam;
	BOOL	bIsPlayer;
	POINT	posLT;
	DWORD	dwDir;

	int		nLife;					
	int		nSpeed;
	int		nPower;
	int		nFire;
	DWORD	dwEquip;	
	DWORD	dwReserved[4];
}TANKINFO, * LPTANKINFO;


typedef struct tagBLOCK {
	BYTE		byObstacle;			// land obstacle
	BYTE		byClass;			// landform kind
	WORD		wExParam;			// extra data
}BLOCK, * LPBLOCK;


//-----------------------------------------------------------------------------
// Name: class MapInfo
// Desc: Class to handle all data of the map 
//-----------------------------------------------------------------------------
class CMapInfo
{
	friend class	ConsoleNet;

	char			*m_szFileName;
	bool			m_bReversed;
	int				m_nBlocks;
	int				m_cxBlocks;
	int				m_cyBlocks;

	unsigned int	m_uiTankNum;

	POINT			*m_ptBase;
	BLOCK			*m_pBlocks;
	TANKINFO		*m_pTankInfo;

public:
	CMapInfo();
	~CMapInfo();

	// Status function
	bool			IsReversed()		{ return m_bReversed; }

	// Access functions
	const char		*GetMapFileName()	{ return m_szFileName; }
	void			SetReversed( bool flag );
	unsigned int	GetObjectNum( DWORD type )		{ return m_uiTankNum; }

	// Creation/destruction methods
	bool			LoadMap(const char *filename);
	void			DestroyMap();

	// Methods
	void			ConvertCoord( CObject * pobj );
	void			Protect( RECT rt, bool flag, POINT *ppts, int &changed );

	// Methods of operations on map data
	void		VerReverseBlock( int x, int y );
	void		HorReverseBlock( int x, int y );
	bool		VerReverseMap();
	bool		HorReverseMap();
	bool		CenterRotate180();
	int			BlockCounter( DWORD land, CObjBlock *pobb );

	// Resource locator
	bool		BlockLocator( int x, int y, RECT *prc, int &level );
	bool		ObjectLocator( CObject *pobj, RECT *prc, int &level );
	bool		ObjBlockLocator( CObjBlock *poblk, RECT *prc, int &level );

	// Collision test
	void		ColRToMobile( RECT &rt, POINT step, CMobileObject **ppmos,
							 int num, int except, UINT team, bool checkteam,
							 int &hit );
	void		ColRToB( POINT &lt, WidthType wt, POINT step, DWORD block_land, 
						  DWORD &over_land, DWORD remove_land, POINT *ptChanged,
						  int &changed );

protected:
	void		Get4Mask( int left, int top, int *mask ); 
	void		Get4Mask16( int left, int top, int *mask);
	bool		ColR2R( RECT &rt_move, RECT rt_stable, POINT step );

};

#endif	// _ASIDER_TANK_ALPHA3_MAPINFO_H_

⌨️ 快捷键说明

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