daily pastebin goal
42%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// \file object.cpp
  2. /// Code for the game object class CGameObject.
  3.  
  4. #include "object.h"
  5.  
  6. #include "Timer.h"
  7.  
  8. extern CTimer g_cTimer;
  9. extern int g_nScreenHeight;
  10.  
  11. /// Constructor for a game object.
  12. /// \param objecttype Object type.
  13.  
  14. CGameObject::CGameObject(GameObjectType objecttype){ //constructor
  15.   m_nObjectType = objecttype;
  16.   m_vPosition = m_vOldPos = D3DXVECTOR2(0, 0);
  17.   m_nFrictionTime = g_cTimer.time();
  18.  
  19.   if(objecttype == CUEBALL_OBJECT)
  20.       m_vOldPos = D3DXVECTOR2(295.0f,(float)g_nScreenHeight/2.0f);
  21.   if(objecttype == EIGHTBALL_OBJECT)
  22.       m_vOldPos = D3DXVECTOR2(750.0f,(float)g_nScreenHeight/2.0f);
  23.  
  24. } //constructor
  25.  
  26. /// Move in proportion to velocity vector and time since last move, and apply
  27. /// a small amount of friction to reduce the velocity.
  28.  
  29. void CGameObject:: move(){
  30. D3DXVECTOR2 vTemp;
  31.  
  32. vTemp = m_vPosition; //save
  33. m_vPosition += 0.93f*(m_vPosition - m_vOldPos);//update
  34. m_vOldPos = vTemp; //remember
  35.  
  36. if((m_vPosition < m_vOldPos)){
  37.     m_bAtRest = TRUE;
  38. }
  39.  
  40. } //move
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top