Page 1 of 1

rotation of items, not using matrix

Posted: Thu Jul 05, 2018 12:53 pm
by guialtran
this function is very similar to TurnBoat (boat, direction), is made to rotate items that are not in an matrix.

Code: Select all

//DIRection 1=right, 2=flip, 3=left

my_RotatePoint( who, struct{"x":=item.x,"y":=item.y} , 1);

function my_RotatePoint( byref pivo, byref ponto , dir)
    var difx := pivo.x - ponto.x;
    var dify := pivo.y - ponto.y;
    case (dir)
        1: // Right
            ponto.x := pivo.x + dify;
            ponto.y := pivo.y - difx;

        2: // Flip
            ponto.x := pivo.x + difx;
            ponto.y := pivo.y + dify;

        3: // Left
            ponto.x := pivo.x - dify;
            ponto.y := pivo.y + difx;
    endcase
endfunction
there is only the calculation of mathematics.
you can adapt it to receive 1 object or a list.

Re: rotation of items, not using matrix

Posted: Thu Jul 05, 2018 1:11 pm
by guialtran