Guest User

CEntity::ResolveEntityCircleCollision

a guest
Jun 7th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. void CEntity::ResolveEntityCircleCollision(const CBoundingBox* collision, CBoundingCircle* entity, const TVector2& velocity)
  2. {
  3.     // Moving right; Hit the left side of the entity
  4.     if (velocity.X > 0)
  5.     {
  6.         entity->SetX(collision->GetX() - entity->GetRadius());
  7.     }
  8.     // Moving left; Hit the right side of the entity
  9.     if (velocity.X < 0)
  10.     {
  11.         entity->SetX(collision->GetX() + collision->GetW() + entity->GetRadius());
  12.     }
  13.     // Moving down; Hit the top side of the entity
  14.     if (velocity.Y > 0)
  15.     {
  16.         entity->SetY(collision->GetY() - entity->GetRadius());
  17.     }
  18.     // Moving up; Hit the bottom side of the entity
  19.     if (velocity.Y < 0)
  20.     {
  21.         entity->SetY(collision->GetY() + collision->GetH() + entity->GetRadius());
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment