www.pudn.com > MyGame.rar > GameObj.cpp


// GameObj.cpp: implementation of the CGameObj class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "MyGame.h" 
#include "GameObj.h" 
 
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char THIS_FILE[]=__FILE__; 
#define new DEBUG_NEW 
#endif 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
CGameObj::CGameObj() 
{ 
	p=Point3f(0,0,0); 
	v=Point3f(0,0,0); 
	angle=0; 
	av=0; 
	axis=Point3f(0,0,1); 
	active=true; 
	B.r=1; 
} 
 
CGameObj::CGameObj(const Point3f &_p, const float _angle) 
{ 
	B.r=1; 
	p=_p; 
	v=Point3f(0,0,0); 
	angle=_angle; 
	av=0; 
	axis=Point3f(0,0,1); 
	active=true; 
} 
 
CGameObj::CGameObj(const Point3f &_p, const float _angle, const Point3f &_v) 
{ 
	B.r=1; 
	p=_p; 
	v=_v; 
	angle=_angle; 
	av=0; 
	axis=Point3f(0,0,1); 
	active=true; 
} 
 
CGameObj::~CGameObj() 
{ 
 
} 
 
bool CGameObj::Collide(CGameObj *o) 
{ 
	B.c=p; 
	o->B.c=o->p; 
	return B.Intersect(o->B); 
} 
 
void CGameObj::DrawBound() 
{ 
	glPushMatrix(); 
	glTranslate(p); 
	glutWireSphere(B.r,8,5); 
	glPopMatrix(); 
}