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

📄 gameobjectgraph.h

📁 游戏框架
💻 H
字号:
// ***************************************************************
//  GameObjectGraph   version:  1.0
//  -------------------------------------------------------------
//	File Name:	GameObjectGraph.h
//	Created:	2007/07/20
//	Modified:	2007/07/20   12:34
//	Author:		Ben
//  Msn:		bwenpig@gmail.com
//  Email:		bwenpig@gmail.com
//	Description:
//
//	Purpose:	
//  -------------------------------------------------------------
//  license:
//
//  The contents of this file are subject to the Mozilla Public
//  License Version 1.1 (the "License"); you may not use this file
//  except in compliance with the License. You may obtain a copy
//  of the License at http://www.mozilla.org/MPL/ Software dis-
//  tributed under the License is distributed on an "AS IS" 
//  basis, WITHOUT WARRANTY OF ANY KIND, either express or im-
//  plied. See the License for the specific language governing
//  rights and limitations under the License.
//
//  The Initial Developer of the Original Code is Ben .
//  Copyright (C) 2007 - All Rights Reserved.
// ***************************************************************
#pragma once
#include "objectcom.h"
#include "GameObject.h"
//#define GetDistance((_POINT)A,(_POINT)B) (return (int)sqrt((B.x-A.x)*(B.x-A.x)+(B.y-A.y)*(B.y-A.y)))

#define		DOTLINE_PITCH		10		//虚线间隔


class OBJECT_COM_CLASS CGameObjectGraph :
	public IGameObjectGraph , public CGameObject
{
private:
	/**
	 * 背景颜色
	 */
	DWORD m_dwBackGroundColor;
	/**
	 * 边框颜色
	 */
	DWORD m_dwBorderColor;
	/**
	 * 图形类型
	 */
	enGraphLine m_enGraphLine;
	/**
	 * 线类型
	 */
	enGraphType m_enGraphType;
	/**
	 * 椭圆率
	 */
	float m_fEllipticity;
	/**
	 * 圆形半径
	 */
	float m_fRadii1;
	float m_fRadii2;
	/**
	 * 图形的顶点(暂时最多为4个)
	 */
	_POINT m_piPoints[4];
	/**
	 * 边框宽度
	 */
	WORD m_wBorderWidth;
	hgeSprite*		m_hgeSprite;					//精灵类指针
	HTARGET			m_hTarget;						//渲染目标
	HTARGET			m_hPreTarget;					//渲染目标
	_SIZE			m_siTarget;						//渲染大小
	CResource*		m_pResource;					//资源指针

public:
	CGameObjectGraph(void);
	virtual ~CGameObjectGraph(void);

protected:
	/**
	 * 画圆形
	 */
	void DrawCircular();
	/**
	 * 画线
	 */
	void DrawLine(_POINT piStart, _POINT piEnd);
	/**
	 * 画方体
	 */
	void DrawSquare();
	/**
	 * 画三角形
	 */
	void DrawTriangle();

	//公共相关方法
public:
	/**
	 * 重绘纹理
	 */
	virtual void __cdecl ReDraw();
	//渲染对象
	virtual void __cdecl Render(WPARAM wParam=NULL);
	//重获焦点 Randy 8-27
	virtual void __cdecl FocusGain();

public:
	/**
	 * 对象创建
	 */
	virtual bool __cdecl Create(LPCTSTR lpName, _SIZE siSize, CResource* pResource, enGraphType enGraphType = Graph_Square, enGraphLine enGraphLine = Line_Normal, WORD wBorderWidth = 1, DWORD dwBackGroundColor = 0, DWORD dwBorderColor = 0xFFFFFFFF);
	/**
	 * 对象创建(三角形)
	 */
	virtual bool __cdecl Create(LPCTSTR lpName, _SIZE siSize, CResource* pResource, _POINT piPoint1, _POINT piPoint2, _POINT piPoint3);
	/**
	 * 对象创建(线形)
	 */
	virtual bool __cdecl Create(LPCTSTR lpName, _SIZE siSize, CResource* pResource, _POINT piPoint1, _POINT piPoint2);
	/**
	 * 对象创建(圆形)
	 */
	virtual bool __cdecl Create(LPCTSTR lpName, _SIZE siSize, CResource* pResource, float fRadii1, float fRadii2);
	/**
	 * 设置背景颜色
	 */
	virtual void __cdecl SetBackGroundColor(DWORD dwColor);
	/**
	 * 设置边框颜色
	 */
	virtual void __cdecl SetBorderColor(DWORD dwColor);
	/**
	 * 设置边框宽度
	 */
	virtual void __cdecl SetBorderWidth(WORD wWidth);
	/**
	 * 设置圆形的参数
	 */
	virtual void __cdecl SetCircular(float fRadii, float fEllipticity);
	/**
	 * 设置图形类型
	 */
	virtual void __cdecl SetGraphType(enGraphType enGraphType);
	/**
	 * 设置线的类型
	 */
	virtual void __cdecl SetLineType(enGraphLine enGraphLine);
	/**
	 * 设置三角形参数
	 */
	virtual void __cdecl SetTriangle(_POINT piPoint1, _POINT piPoint2, _POINT piPoint3);
	/**
	 * 设置混和模式
	 */
	virtual void __cdecl SetBlendMode(int nBlendMode);
	/**
	 * 设置背景纹理
	 */
	virtual void __cdecl SetBackGround(CResource* pResource);
	/**
	 * 返回背景颜色
	 */
	virtual DWORD __cdecl GetBackGroundColor();
	/**
	 * 返回边框颜色
	 */
	virtual DWORD __cdecl GetBorderColor();
	/**
	 * 返回边框宽度
	 */
	virtual WORD __cdecl GetBorderWidth();
	/**
	 * 返回图形类型
	 */
	virtual enGraphType __cdecl GetGraphType();
	/**
	 * 返回线的类型
	 */
	virtual enGraphLine __cdecl GetLineType();
	/**
	 * 返回背景纹理
	 */
	virtual CResource* __cdecl GetBackGround();
	/**
	 * 调整各顶点
	 */
	virtual void __cdecl AdjustPoints(_LPPOINT pPoints, WORD wLen);
	/**
	 * 调整大小(有别于SetSize的缩放)
	 */
	virtual void __cdecl AdjustPoints(_SIZE siSize);

	//模板方法
public:
	//是否有效
	virtual bool __cdecl IsValid() { return AfxIsValidAddress(this,sizeof(CGameObjectGraph))?true:false;};
	//释放对象
	virtual bool __cdecl Release() { if (IsValid()) delete this; return true; };
	//接口查询
	virtual void * __cdecl QueryInterface(const IID & Guid, DWORD dwQueryVer);

public:
	//操作重载
	CGameObjectGraph& operator=(CGameObjectGraph& GameObject);
};

⌨️ 快捷键说明

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