Registriert seit: 6. Okt 2010
Ort: 72661 Grafenberg
181 Beiträge
Turbo Delphi für Win32
|
AW: Tetris mit Canvas funktioniert nicht wie es soll
5. Mär 2013, 22:39
Delphi-Quellcode:
procedure THaupt.findelinie;
var
i,j,k,max,anzahl : integer;
temp : array[1..16] of integer;
begin
gfblock.Clear;
max := 0;
anzahl := 0;
for i := 1 to high(Block) do
begin
if 27-Block[i].fPosition.Y > max then max := 27-Block[i].fPosition.Y ;
gfblock.Add(inttostr(Block[i].fPosition.X)+','+inttostr(Block[i].fPosition.y)+','+colortostring(Block[i].ffarbe) );
end;
for j := 0 to max do
begin
for i := 1 to high(Block) do
begin
if Block[i].fPosition.Y = j then
begin
anzahl:= anzahl+1;
temp[anzahl] := i;
end;
if anzahl = 16 then
begin
gfblock.Move(temp[1],high(Block)-1);
gfblock.Move(temp[2],high(Block)-2);
gfblock.Move(temp[3],high(Block)-3);
gfblock.Move(temp[4],high(Block)-4);
gfblock.Move(temp[5],high(Block)-5);
gfblock.Move(temp[6],high(Block)-6);
gfblock.Move(temp[7],high(Block)-7);
gfblock.Move(temp[8],high(Block)-8);
gfblock.Move(temp[9],high(Block)-9);
gfblock.Move(temp[10],high(Block)-10);
gfblock.Move(temp[11],high(Block)-11);
gfblock.Move(temp[12],high(Block)-12);
gfblock.Move(temp[13],high(Block)-13);
gfblock.Move(temp[14],high(Block)-14);
gfblock.Move(temp[15],high(Block)-15);
gfblock.Move(temp[16],high(Block)-16);
gfblock.Delete(high(block)-1);
gfblock.Delete(high(block)-2);
gfblock.Delete(high(block)-3);
gfblock.Delete(high(block)-4);
gfblock.Delete(high(block)-5);
gfblock.Delete(high(block)-6);
gfblock.Delete(high(block)-7);
gfblock.Delete(high(block)-8);
gfblock.Delete(high(block)-9);
gfblock.Delete(high(block)-10);
gfblock.Delete(high(block)-11);
gfblock.Delete(high(block)-12);
gfblock.Delete(high(block)-13);
gfblock.Delete(high(block)-14);
gfblock.Delete(high(block)-15);
gfblock.Delete(high(block)-16);
arraykurzen;
end
else neu;
end;
end;
end;
procedure THaupt.arraykurzen;
var
sl : TStringlist;
i : integer;
x,y : integer;
farbe : Tcolor;
begin
setlength(Block,0);
sl := TStringlist.Create;
for i := 0 to gfblock.Count- 1 do
begin
sl.CommaText := gfblock[i];
x := strtoint(sl[0]);
y := strtoint(sl[1]);
farbe := stringtocolor(sl[2]);
setlength(Block, Length(Block)+1);
Block[high(Block)].fPosition.X := x;
Block[high(Block)].fPosition.X := y;
Block[high(Block)].fFarbe := farbe;
sl.Clear;
end;
findelinie;
end;
Delphi bleibt jedesmal stehen wenn es einen neuen Block erzeugen soll warum?
Thomas ich hab jetzt gemerkt warum eine Liste besser gewesen wäre als eine array
|
|
Zitat
|