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

📄 game_panel.h

📁 我做的毕业设计
💻 H
字号:

#pragma once
#include <tchar.h>
#include <d3dx9.h>
#include <d3dx9mesh.h>
#include <mmsystem.h>
#include "Game_SkinMesh.h"

#define PANEL_D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)

#ifndef SAFE_RELEASE
#define SAFE_RELEASE(p) if(p) {p->Release();p=NULL;}
#endif
#ifndef SAFE_DELETE
#define SAFE_DELETE(p) if(p) {delete p;p=NULL;}
#endif

class CPanel
{
private:
	//FVF
	struct PANEL_CUSTOMVERTEX
	{
		FLOAT x, y, z;		//三维坐标
		DWORD colour;		//颜色
		FLOAT u, v;			//纹理坐标
	};

public:
	CPanel(LPDIRECT3DDEVICE9 pD3DDevice, float nWidth, float nHeight, int nScreenWidth, int nScreenHeight, DWORD dwColour = -1, DWORD dwType = 0);//构造函数	
	bool	Render();//渲染
	void	MoveTo(float x, float y);//移动二维窗口的位置
	void	MoveToMouse(float x, float y);//跟随鼠标移动二维窗口的位置
	bool	SetTexture(const char *szTextureFilePath, DWORD dwKeyColour = 0);//载入纹理
	bool	IsPointInsidePanel(float x, float y);//判断点是否在其上
	//void	setSize( float nWidth,float nHeight,float fBUV=1.0f,float fAUV=0.0f);//设置尺寸
	void	setSize( float nWidth,float nHeight);//设置尺寸
	virtual ~CPanel();//析构函数
	void	SetDepth(float fDepth = 1.0f){m_fDepth = fDepth;}
	void	SetWidth(float fB) {m_fRate = fB; UpdateVertices();}
	void	SetAngle(float angle = 0.0f) {m_fAngle = angle + D3DX_PI;}
	bool	UpdateVertices(float fBUV=1.0f,float fAUV=0.0f);//刷新顶点
	//bool	UpdateVertices();
	D3DXVECTOR3	GetPos() {return D3DXVECTOR3((float)m_nX, (float)m_nY, 0.0f);}


	static void Button1(CSkinMesh* RoleMesh);
	static void Button2(CSkinMesh* RoleMesh);
	static void Button3(CSkinMesh* RoleMesh);
	static void Button4(CSkinMesh* RoleMesh);
	static void Button5(CSkinMesh* RoleMesh);
	void SetPro(float x,float y);
	void (*p)(CSkinMesh* RoleMesh);
	
	void SetRoleHP(float hp);
	void SetRoleMP(float mp);
	void SetEnemyHP(float hp);
	void SetEnemyMP(float mp);
	void SetButton(int i)
	{
		switch(i)
		{
		case 1:
			p=Button1;
			del=false;
			break;
		case 2:
			p=Button2;
			del=false;
			break;
		case 3:
			p=Button3;
			del=true;
		    break;
		case 4:
			p=Button4;
			del=true;
		    break;
		case 5:
			p=Button5;
			del=false;
			break;	
		}
	}

private:

	bool	CreateVertexBuffer();//创建顶点缓冲
	LPDIRECT3DDEVICE9			m_pD3DDevice;
	LPDIRECT3DVERTEXBUFFER9		m_pVertexBuffer;
	LPDIRECT3DTEXTURE9			m_pTexture;
	int							m_nScreenWidth;
	int							m_nScreenHeight;
	DWORD						m_dwColour;
	DWORD						m_dwType;

	float						m_fDepth;
	float						m_fRate;
	//float						m_nX;
	//float						m_nY;
public:
	float						m_fAngle;
	bool						m_bPick;
	bool						del;
	float						m_nX;
	float						m_nY;
	float						m_nWidth; 
	float						m_nHeight;
};

⌨️ 快捷键说明

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