Vorinformationen:
Ich bin z.Z. ein kleine Spiel am programmieren, welches aber noch lange nicht Fertig ist, im Anhang hab ich mal das Spiel hinzugefügt.
So nun hab ich ein Problem, beim verschieben der AIShips flackern alle bilder, und eine Option wie Buffering o.ä. hab ich nicht gefunden.
Um die Images auf die Form zu bringen, nutze ich Arrays und TImage
Code:
Delphi-Quelltext
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:
| procedure Ship1Init; var AIShip1 : integer; PosY : integer; begin ButtonKlick:=true; PosY:=10; for AIShip1 := 0 to ShipProRunde -1 do begin Main.AIShip1Typ[AIShip1]:=TImage.Create(Form1); AIShip1Typ[AIShip1].Parent:= Form1; AIShip1Typ[AIShip1].picture.LoadFromFile(ExtractFilePath(ParamStr(0))+'ship1.png'); AIShip1Typ[AIShip1].autosize:=true; AIShip1Typ[AIShip1].Visible:=true; AIShip1Typ[AIShip1].Top:=PosX; AIShip1Typ[AIShip1].Left:=PosY; AIShip1AttTyp[AIShip1]:=AIShip1Att; AIShip1DeffTyp[AIShip1]:=AIShip1Deff; AIShip1RangeTyp[AIShip1]:=AIShip1Range; ShipVisi:=false; PosY:=PosY+50; if (PosY>=600) then begin PosY:=0; end; end; end; |
und hier das bewegen
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
| for Ship1 := 0 to ShipProRunde -1 do begin AIShip1Typ[Ship1].Top:=AIShip1Typ[Ship1].Top+stepX; AIShip1Typ[Ship1].Left:=PosY; PosY:=PosY+50; if (PosY>=600) then begin PosY:=0; PosX:=PosX+1; end; end; |
wie ihr im Programm sehen könnt, flackern die Bilder richtig heftig, sobald man die Spiel Geschwindigkeit hoch dreht.
Aber wie kann ich das verhindern?