GAMEOBJ.CPP
Upload User: nthssl
Upload Date: 2022-04-05
Package Size: 25357k
Code Size: 1k
Category:

OpenCV

Development Platform:

Visual C++

  1. // GameObj.cpp: implementation of the CGameObj class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "MyGame.h"
  6. #include "GameObj.h"
  7. #ifdef _DEBUG
  8. #undef THIS_FILE
  9. static char THIS_FILE[]=__FILE__;
  10. #define new DEBUG_NEW
  11. #endif
  12. //////////////////////////////////////////////////////////////////////
  13. // Construction/Destruction
  14. //////////////////////////////////////////////////////////////////////
  15. CGameObj::CGameObj()
  16. {
  17. p=Point3f(0,0,0);
  18. v=Point3f(0,0,0);
  19. angle=0;
  20. av=0;
  21. axis=Point3f(0,0,1);
  22. active=true;
  23. B.r=1;
  24. }
  25. CGameObj::CGameObj(const Point3f &_p, const float _angle)
  26. {
  27. B.r=1;
  28. p=_p;
  29. v=Point3f(0,0,0);
  30. angle=_angle;
  31. av=0;
  32. axis=Point3f(0,0,1);
  33. active=true;
  34. }
  35. CGameObj::CGameObj(const Point3f &_p, const float _angle, const Point3f &_v)
  36. {
  37. B.r=1;
  38. p=_p;
  39. v=_v;
  40. angle=_angle;
  41. av=0;
  42. axis=Point3f(0,0,1);
  43. active=true;
  44. }
  45. CGameObj::~CGameObj()
  46. {
  47. }
  48. bool CGameObj::Collide(CGameObj *o)
  49. {
  50. B.c=p;
  51. o->B.c=o->p;
  52. return B.Intersect(o->B);
  53. }
  54. void CGameObj::DrawBound()
  55. {
  56. glPushMatrix();
  57. glTranslate(p);
  58. glutWireSphere(B.r,8,5);
  59. glPopMatrix();
  60. }