Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1.     bool collided = false;
  2.     for(Entity* e : Entity::instances)
  3.     {
  4.         if (e == this)
  5.         {
  6.             continue;
  7.         }
  8.  
  9.         if (e->entClass == "ENTITY_MISSILE")
  10.         {
  11.             Missile* m = (Missile*)e;
  12.             if (abs(position.x - m->position.x) * 2 < (boundingbox.w + m->boundingbox.w))
  13.             {
  14.                 if (abs(position.y - m->position.y) * 2 < (boundingbox.h + m->boundingbox.h))
  15.                 {
  16.                     collided = true;
  17.                     break;
  18.                 }
  19.             }
  20.         }
  21.     }
  22.     if (collided)
  23.     {
  24.         TakeDamage();
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement