SHARE
TWEET

move link out of solid objects

a guest Nov 16th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int RotateDirNum(int d, int n){
  2.     for (int i = 0; i < n; ++i) {
  3.         if ( d == DIR_UP )
  4.             d = DIR_RIGHT;
  5.         else if ( d == DIR_RIGHT )
  6.             d = DIR_DOWN;
  7.         else if ( d == DIR_DOWN )
  8.             d = DIR_LEFT;
  9.         else
  10.             d = DIR_UP;
  11.     }
  12.     return d;
  13. }
  14.  
  15. int i; int j; int x = Link->X; int y = Link->Y;
  16. if ( Screen->isSolid(Link->X+8, Link->Y+8) ) {
  17.     for (i = 1; i < 6; ++i) {
  18.         for (j = 0; j < 4; ++j) {
  19.             x = Link->X+8+VectorX(8*i, DirAngle(RotateDirNum(Link->Dir, j)));
  20.             y = Link->Y+8+VectorY(8*i, DirAngle(RotateDirNum(Link->Dir, j)));
  21.             if ( !Screen->isSolid(x, y) ) {
  22.                 i = 9999;
  23.                 j = 4;
  24.             }
  25.         }
  26.     }
  27.     if ( i >= 9999 ) {
  28.         Link->X = x-8;
  29.         Link->Y = y-8;
  30.     }
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top