1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
   |  
TPanel *Panel = (TPanel*)Sender;
TPoint P = Point(Panel->Left, Panel->Top);
if(IsMoving)
    {
    if(Vertical)
        {
        P.y = P.y + Y - Start.y;
        }
    else
        {
        P.x = P.x + X - Start.x;
        }
 
    //En vrac...
    TPoint Z = Point(P.x + Panel->Width, P.y + Panel->Height);
 
    if(P.y < ZoneDuJeu.Top) P.y = ZoneDuJeu.Top;
    if(Z.y > ZoneDuJeu.Bottom) P.y = ZoneDuJeu.Bottom - Panel->Height;
 
    if(P.x < ZoneDuJeu.Left) P.x = ZoneDuJeu.Left;
    if(Z.x > ZoneDuJeu.Right) P.x = ZoneDuJeu.Right - Panel->Width;
 
    if(Intercept(Panel, P) != NULL)
        {
        ShowMessage("Collision");
        IsMoving = false;
        }
    else
        {
        Panel->SetBounds(P.x, P.y, Panel->Width, Panel->Height);
        }
    } |