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

📄 sprite.h

📁 Torus3D.rar,BREW平台的3D游戏引擎的一个实例.喜欢的朋友可以下载
💻 H
字号:
// ==========================================================================================================
//
// BREW v2.0+ OPENGLES MICROENGINE
//
// ----------------------------------------
//
// Written by Vander Nunes
//
// ==========================================================================================================

#ifndef __SPRITE_H__

	#define __SPRITE_H__

	#include "AEEShell.h"						// Shell interface definitions
	#include "AEEFile.h"						// File interface definitions
	#include "AEEImage.h"						// Image interface
	#include "AEEStdLib.h"					// Standard library
	#include "torus.h"
	#include "vfs.h"


	typedef struct _sprframe
	{
		int16	jOffx, jOffy;					// frame offset
		int16	jAddx, jAddy;					// frame centralization add compensation (on variable frame sizes)
		short	iW, iH;								// frame width and height
	} sprframe;


	class CSprite
	{
		private:

			CEngine*		m_pEngine;
			boolean			bUseSysFree;			// method for deallocation of pBuffer

			byte			jNFrames;					// number of frames
			char			jCurrFrame;				// current frame
			char			jAnimDir;					// direction of animation (1:forward or -1:backward)
			short			iW, iH;						// sprite width and height
			short			iMinfw, iMaxfw;		// minimum and maximum frame width (all frames)
			int16			iPx, iPy;					// position coordinates of the sprite
			uint16		wFrameTime;				// time (in ticks) for each frame of anim
			boolean		bFlag1;						// generic flag (sprite dependant)
			boolean		bFlag2;						// generic flag (sprite dependant)
			sprframe*	pFrames;					// array of width and heights for each sprite's frame
			void*			pBuffer;					// sprite in native format (BitBlt compatible)

		public:

			CSprite(CEngine* pEngine);
			~CSprite();

			// release memory
			void			CleanUp();

			// load 2D sprite bitmap from the game dat file (vfs)
			boolean		LoadFromVfs(char* szVfsFile, char* szFile);

			// load 2D sprite image from conventional resource file
			boolean		LoadFromRes(char* szResFile, int16 sRes);

			// configure sprite frames
			void			Config(byte jNFrames, int16* pFramesData);

			// set manually the current frame
			void			SetFrame(byte jFrame);

			// time-based update of current animation frame
			void			StepAnim(byte jFirst, byte jLast, uint16 wTickTime, uint16 wTicksElapsed, boolean bLoop, boolean bPingPong);

			// draw current frame
			void			Draw(int iPx, int iPy);

			// draw a number
			void			DrawNumber(int iPx, int iPy, char* szNumber);

			// draw a text in the range (spc)!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ
			// (ascii 32 .. 90)
			void			DrawText32To90(int iPx, int iPy, char* szText);

			short			Width();
			short			Height();
	};

#endif

⌨️ 快捷键说明

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