Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// \file object.cpp
- /// Code for the game object class CGameObject.
- #include "object.h"
- #include "Timer.h"
- extern CTimer g_cTimer;
- extern int g_nScreenHeight;
- /// Constructor for a game object.
- /// \param objecttype Object type.
- CGameObject::CGameObject(GameObjectType objecttype){ //constructor
- m_nObjectType = objecttype;
- m_vPosition = m_vOldPos = D3DXVECTOR2(0, 0);
- m_nFrictionTime = g_cTimer.time();
- if(objecttype == CUEBALL_OBJECT)
- m_vOldPos = D3DXVECTOR2(295.0f,(float)g_nScreenHeight/2.0f);
- if(objecttype == EIGHTBALL_OBJECT)
- m_vOldPos = D3DXVECTOR2(750.0f,(float)g_nScreenHeight/2.0f);
- } //constructor
- /// Move in proportion to velocity vector and time since last move, and apply
- /// a small amount of friction to reduce the velocity.
- void CGameObject:: move(){
- D3DXVECTOR2 vTemp;
- vTemp = m_vPosition; //save
- m_vPosition += 0.93f*(m_vPosition - m_vOldPos);//update
- m_vOldPos = vTemp; //remember
- if((m_vPosition < m_vOldPos)){
- m_bAtRest = TRUE;
- }
- } //move
Add Comment
Please, Sign In to add comment