Advertisement
Guest User

Skew

a guest
Jun 28th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.72 KB | None | 0 0
  1. procedure mapSkew;
  2. var
  3.   Box, roadBox: TBox;
  4.   bridgeCol,bankCol,floorCol,roadCol,roadCol2,preferredRoad: TcolEx;
  5.   TPA,floorTPA,test4,test5: TPointArray;
  6.   walkPoint,singlePoint,leftSort,rightSort,symbolPnt,symbolPnt2,newPoint: Tpoint;
  7.   foundBank,foundAltar: boolean;
  8.   newX,newY : extended;
  9.   angle: extended;
  10.  
  11. begin
  12. roadCol.create(6579564,7,0.7,0.7);
  13.   roadCol2.create(4671311,7,0.7,0.7);
  14.   Box := [561,4,646,164];
  15.   roadBox := [567,22,706,141];
  16.  
  17.   roadCol.findAllIn(roadBox,test4);
  18.   roadCol2.findAllIn(roadBox,test5);
  19.  
  20.   if (length(test4) = 0) and (length(test5) = 0) then
  21.     begin
  22.       writeLn('** Not in view of the road or none of the colors for the road are working **');
  23.     end;
  24.  
  25.   if (length(test4) > length(test5)) then
  26.     begin
  27.       writeLn('Preferred road color is Road 1');
  28.         preferredRoad := roadCol;
  29.     end;
  30.  
  31.   if (length(test5) > length(test4)) then
  32.     begin
  33.       writeLn('Preferred road color is Road 2');
  34.         preferredRoad := roadCol2;
  35.     end;
  36.  
  37. writeLn('Preferred road color is: ',preferredRoad);
  38.  
  39.   preferredRoad.findAllIn(roadBox,TPA);
  40.  
  41.   writeLn('Road TPA length: ',length(TPA));
  42.  
  43.   if (length(TPA) > 0) then
  44.     begin
  45.       writeLn('Checking Middle');
  46.       sortTPAFrom(TPA,point(553,57));
  47.         LeftSort := TPA[0];
  48.       sortTPAFrom(TPA,point(725,37));
  49.         RightSort := TPA[0];
  50.           newX := Floor((RightSort.X + LeftSort.X)/2);
  51.           newY := Floor((RightSort.Y + LeftSort.Y)/2);
  52.  
  53.         writeLn(newx,','newy);
  54.         writeLn('LeftSort: ',leftSort,' RightSort: ',rightSort);
  55.         //angle := arctan2(leftSort.y - rightSort.y, leftSort.x - rightSort.x);
  56.         //angle := arctan2(rightSort.y - leftSort.y, rightSort.x - leftSort.x );
  57.         //atan2(x1 * y2 - y1 * x2,  x1 * x2 + y1 * y2)
  58.         //angle := arctan2((leftsort.X * (rightsort.y) - leftsort.y * (rightsort.x)),(leftsort.x * (rightsort.x) + leftsort.y * (rightsort.Y)));
  59.         angle := ((arctan2(rightSort.y - leftSort.y, rightSort.x - leftSort.x) / pi) * 180);
  60.  
  61.         if (angle > 0) then
  62.           begin
  63.             newPoint := point(MMCX + round(25 * cos(angle)), MMCY + round(50 * sin(angle)));
  64.             writeLn('Angle: ',angle);
  65.             writeLn('New Point: ',newPoint);
  66.             humanMMouse(newpoint,0,0);
  67.               wait(1000);
  68.           end;
  69.  
  70.         if (angle < 0) then
  71.           begin
  72.             angle := ((arctan2(leftSort.y - rightSort.y, leftSort.x - rightSort.x) / pi) * 180);
  73.             newPoint := point(MMCX + round(25 * cos(angle)), MMCY + round(50 * sin(angle)));
  74.             writeLn('Angle: ',angle);
  75.             writeLn('New Point: ',newPoint);
  76.             humanMMouse(newpoint,0,0);
  77.               wait(1000);
  78.           end;
  79.     end;
  80.  
  81. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement