void CBulletPaper::Update(float fElapsedTime) { CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance(); CSGD_MessageSystem *pMS = CSGD_MessageSystem::GetInstance(); CGamePlay *pGP = CGamePlay::GetInstance(); SetPosX(GetPosX() + GetVelX() * fElapsedTime); SetPosY(GetPosY() + GetVelY() * fElapsedTime); rCollisionRect.top = GetPosY(); rCollisionRect.left = GetPosX(); rCollisionRect.bottom = GetPosY() + GetHeight(); rCollisionRect.right = GetPosX() + GetWidth(); CBase *player; player = CPlayerCharacter::GetInstance(); RECT cross; if (IntersectRect(&cross,&rCollisionRect,&player->GetCollisionRect())) pMS->SendMsg(new CCollisionMessage(player,this)); if (GetPosY() > 580 || GetPosY() < -100 || GetPosX() > 740 || GetPosX() < -100) pMS->SendMsg(new CDestroyMessage(this)); }
void CBulletHook::Update(float fElapsedTime) { CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance(); CSGD_MessageSystem *pMS = CSGD_MessageSystem::GetInstance(); CGamePlay *pGP = CGamePlay::GetInstance(); CPlayerCharacter *pPC = CPlayerCharacter::GetInstance(); if (GetScoreValue() == 1.0f) { m_fLifeTime -= fElapsedTime; SetPosX(GetPosX() + GetVelX() * fElapsedTime); SetPosY(GetPosY() + GetVelY() * fElapsedTime); } else if (GetScoreValue() == 2.0f) m_fLifeTime -= fElapsedTime * 0.25f; else if (GetScoreValue() == 3.0f) { m_fLifeTime -= fElapsedTime; SetPosX(GetPosX() + GetVelX() * fElapsedTime); SetPosY(GetPosY() + GetVelY() * fElapsedTime); if (GetPosX() < pPC->GetPosX()) SetVelX(abs(GetVelX())); else if (GetPosX() >= pPC->GetPosX()) SetVelX(-abs(GetVelX())); if (GetPosY() < pPC->GetPosY()) SetVelY(abs(GetVelY())); else if (GetPosY() >= pPC->GetPosY()) SetVelY(-abs(GetVelY())); } rCollisionRect.top = GetPosY(); rCollisionRect.left = GetPosX(); rCollisionRect.bottom = GetPosY() + GetHeight(); rCollisionRect.right = GetPosX() + GetWidth(); CBase *player; player = CPlayerCharacter::GetInstance(); RECT cross; if (IntersectRect(&cross,&rCollisionRect,&player->GetCollisionRect())) { pMS->SendMsg(new CCollisionMessage(player,this)); pMS->SendMsg(new CDestroyMessage(this)); } if (m_fLifeTime <= 0) pMS->SendMsg(new CDestroyMessage(this)); }