Guest User

Untitled

a guest
Feb 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.05 KB | None | 0 0
  1. void this_player::checkPortal(bool up, int dir) {
  2.     for(auto i = portals.begin();i!=portals.end();i++) {
  3.         auto other = *i;
  4.         switch(other->pt) {
  5.         case 1:
  6.             if (pdelay > 500 && up && x<other->x+20 && x > other->x-20 && y<other->y+20 && y > other->y-20) {
  7.                 pdelay = 0;
  8.                 if (Map::currentmap == tostring(other->tm)) {
  9.                     for(auto j = portals.begin();j!=portals.end();j++) {
  10.                         auto link = *j;
  11.                         if (other->tn == link->pn) {
  12.                             pdelay = 0;
  13.                             x = link->x;
  14.                             y = link->y-8;
  15.                             ground = 0;
  16.                             break;
  17.                         }
  18.                     }
  19.                 } else {
  20.                     Map::Load(tostring(other->tm), other->tn);
  21.                 }
  22.             }
  23.             break;
  24.         case 2:
  25.             if (pdelay > 500 && up && x<other->x+20 && x > other->x-20 && y<other->y+20 && y > other->y-20) {
  26.                 pdelay = 0;
  27.                 Map::Load(tostring(other->tm), other->tn);
  28.             }
  29.             break;
  30.         case 3:
  31.             if (x<other->x+50 && x > other->x-50 && y<other->y+50 && y > other->y-50) {
  32.                 if (Map::currentmap == tostring(other->tm)) {
  33.                     for(auto j = portals.begin();j!=portals.end();j++) {
  34.                         auto link = *j;
  35.                         if (other->tn == link->pn) {
  36.                             pdelay = 0;
  37.                             x = link->x;
  38.                             y = link->y-8;
  39.                             ground = 0;
  40.                             break;
  41.                         }
  42.                     }
  43.                 } else {
  44.                     Map::Load(tostring(other->tm), other->tn);
  45.                 }
  46.             }
  47.             break;
  48.         case 10:
  49.             other->close = false;
  50.             if (x<other->x+100 && x > other->x-100 && y<other->y+100 && y > other->y-100) {
  51.                 other->close = true;
  52.                 if (pdelay > 500 && up && x<other->x+20 && x > other->x-20 && y<other->y+20 && y > other->y-20) {
  53.                     for(auto j = portals.begin();j!=portals.end();j++) {
  54.                         auto link = *j;
  55.                         if (other->tn == link->pn) {
  56.                             pdelay = 0;
  57.                             x = link->x;
  58.                             y = link->y-8;
  59.                             ground = 0;
  60.                             break;
  61.                         }
  62.                     }
  63.                 }
  64.             }
  65.             break;
  66.         case 12:
  67.             if (vel.ycomp() > 0 && x<other->x+40 && x > other->x-40 && y<other->y+10 && y > other->y-10) {
  68.                 vel.xcomp(300*dir);
  69.                 vel.ycomp(-2200);
  70.             }
  71.             break;
  72.         case 13:
  73.             if (x<other->x+40 && x > other->x-40 && y<other->y+10 && y > other->y-10) {
  74.                 vel.xcomp(other->hi*dir);
  75.                 vel.ycomp(-other->vi);
  76.             }
  77.             break;
  78.         }
  79.        
  80.     }
  81. }
Add Comment
Please, Sign In to add comment