Einzelnen Beitrag anzeigen

Bjoerk

Registriert seit: 28. Feb 2011
Ort: Mannheim
1.384 Beiträge
 
Delphi 10.4 Sydney
 
#15

AW: Tetris mit Canvas funktioniert nicht wie es soll

  Alt 16. Feb 2013, 15:33
Kumpel, du machst mich echt fertig.

Block[high(Block) - 3].fPosition.Y Das ist sehr unsauber (und geht auch nur, weil TBlock in der selben unit steht). Spendier' TBlock mal eine property X und Y, wie ich‘s dir letztens gezeigt habe.

Deine Schleife wird so auch etwas lesbarer. Was soll die eigentlich machen?
Delphi-Quellcode:
  n := high(Block);
  for i := 0 to n do
    if (i <> n - 3) and (i <> n - 2) and (i <> n - 1) and (i <> n - 0) then
      if (Block[n - 3].y + 1 <> Block[i].y) and (Block[n - 3].y + 1 <> 0) then
        if (Block[n - 2].y + 1 <> Block[i].y) and (Block[n - 2].y + 1 <> 0) then
          if (Block[n - 1].y + 1 <> Block[i].y) and (Block[n - 1].y + 1 <> 0) then
            if (Block[n - 0].y + 1 <> Block[i].y) and (Block[n - 0].y + 1 <> 0) then
               kannbewegen := true;
  Mit Zitat antworten Zitat