gameobj.h

来自「基于引擎基础上开发的三维游戏实例“恐怖之战”游戏者可以自爱三维地形上漫游」· C头文件 代码 · 共 67 行

H
67
字号
// GameObj.h: interface for the CGameObj class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_GAMEOBJ_H__8A92C113_DB4A_4228_B334_D7FF039627FC__INCLUDED_)
#define AFX_GAMEOBJ_H__8A92C113_DB4A_4228_B334_D7FF039627FC__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <math.h>
#include <vcg/Point3.h>
#include <vcg/Sphere3.h>
#include <vector>
#include <list>

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
using namespace vcg;
using namespace std;

class CGameObj  
{
public:
	CGameObj();
	CGameObj(const Point3f &_p, const float _angle);
	CGameObj(const Point3f &_p, const float _angle, const Point3f &_v);

	virtual ~CGameObj();

	Point3f p;	  
	Point3f axis;	  
	float angle;  
	Point3f v;  
	float av;
	bool active; 
	Sphere3f B;
	virtual int Draw(){return 0;}
	virtual void Update(int t)
	{
		p += (t/1000.0f*v);
		angle += (t/1000.0f*av);
	};

	Point3f VDir()
	{
		return Point3f(cos(M_PI*angle/180.0),
						 sin(M_PI*angle/180.0),
						 0);
	}; 
	virtual bool Collide(CGameObj *o);
	void DrawBound();
	inline bool operator <  ( CGameObj const & o ) const 
	{
		return	p<o.p;
	}
	inline bool operator == ( CGameObj const & o ) const 
	{
		return (p==o.p && v==o.v);
	}

};

#endif // !defined(AFX_GAMEOBJ_H__8A92C113_DB4A_4228_B334_D7FF039627FC__INCLUDED_)

⌨️ 快捷键说明

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