Einzelnen Beitrag anzeigen

Luis

Registriert seit: 26. Dez 2018
7 Beiträge
 
#7

AW: "Kollidieren" von drei Objekten verhindern

  Alt 26. Dez 2018, 20:17
Ich habe es jetzt mit folgendem Code probiert (natürlich noch in alle Richtungen und mit allen drei Kisten, aber das ist ja prinzipiell gleich aufgebaut)
Delphi-Quellcode:
 if player.top = k1.Top then
 if player.Left =k1.left then
begin
     if k1.Top-50<>k2.Top then
     if k1.Top-50<>k3.Top then
     k1.Top:=k1.Top-50;

     if k1.Top-50 <>k2.Top then
     if k1.Top-50 = k3.top then
     begin
       if k1.Left <>k3.Left then
       k1.Top:=k1.Top-50;

       if k1.Left = k3.Left then
       k1.Top:= k1.Top;
     end;
     if k1.Top-50 = k2.Top then
     if k1.Top-50 <> k3.Top then
     begin
        if k1.Left <>k2.Left then
        k1.Top:=k1.Top-50;

        if k1.Left =k2.Left then
        k1.Top:=k1.Top;
     end;
     if k1.Top-50 = k2.Top then
     if k1.Top-50 = k3.Top then
     begin
       if k1.Left <> k2.Left then
       if k1.Left <> k3.Left then
       k1.Top:=k1.Top-50;

       if k1.Left = k2.Left then
       k1.Top:=k1.Top;

       if k1.Left = k3.Left then
       k1.Top:=k1.Top;
     end;
end;
Hier kollidiert zwar keine Kiste mehr mit einer anderen, allerdings springt gern mal eine Kiste zwei Felder, also 100 Pixel statt den gewünschten 50..
  Mit Zitat antworten Zitat