Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CEntity::ResolveEntityCircleCollision(const CBoundingBox* collision, CBoundingCircle* entity, const TVector2& velocity)
- {
- // Moving right; Hit the left side of the entity
- if (velocity.X > 0)
- {
- entity->SetX(collision->GetX() - entity->GetRadius());
- }
- // Moving left; Hit the right side of the entity
- if (velocity.X < 0)
- {
- entity->SetX(collision->GetX() + collision->GetW() + entity->GetRadius());
- }
- // Moving down; Hit the top side of the entity
- if (velocity.Y > 0)
- {
- entity->SetY(collision->GetY() - entity->GetRadius());
- }
- // Moving up; Hit the bottom side of the entity
- if (velocity.Y < 0)
- {
- entity->SetY(collision->GetY() + collision->GetH() + entity->GetRadius());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment