Registriert seit: 3. Jan 2007
Ort: Dresden
3.443 Beiträge
Delphi 7 Enterprise
|
Re: Fehlersuche: Canvas
5. Feb 2009, 17:05
Du braucsht das Image nur einmal zu löschen. Nicht bei jedem Schliefendurchlauf.
Delphi-Quellcode:
with Image1.Canvas do begin
Rectangle(0,0,Image1.Width, Image1.Height); //hier reicht
for i := 1 to maxObjects do begin
vx[i] := vx[i];
vy[i] := vy[i] + g*T ;
sx[i] := sx[i] + vx[i]*T;
sy[i] := sy[i] + vy[i]*T;
Ellipse(ceil(sx[i]-r[i]),ceil(sy[i]-r[i]), ceil(sx[i]+r[i]), ceil(sy[i]+r[i]));
end;
end;
for i := 1 to maxObjects-1 do begin
for j := i+1 to maxObjects do begin
if Power((r[i]+r[j]),2) > power((sx[i]-sx[j]),2)+power((sy[i]-sy[j]),2) then
begin
vx1 := vx[i];
vx2 := vx[j];
vy1 := vy[i];
vy2 := vy[j];
vx[i] := k*(2*m[j]*vx2+(m[i]-m[j])*vx1)/(m[i]+m[j]);
vx[j] := k*(2*m[i]*vx1+(m[j]-m[i])*vx2)/(m[j]+m[i]);
vy[i] := k*(2*m[j]*vy2+(m[i]-m[j])*vy1)/(m[i]+m[j]);
vy[j] := k*(2*m[i]*vy1+(m[j]-m[i])*vy2)/(m[j]+m[i]);
sx[i] := sx[i] + vx[i]*T;
sx[j] := sx[j] + vx[j]*T;
with Image1.Canvas do begin
//weg mit dem Rechteck
//Rectangle(0,0,Image1.Width, Image1.Height);
Ellipse(ceil(sx[i]-r[i]),ceil(sy[i]-r[i]), ceil(sx[i]+r[i]), ceil(sy[i]+r[i]));
Ellipse(ceil(sx[j]-r[j]),ceil(sy[j]-r[j]), ceil(sx[j]+r[j]), ceil(sy[j]+r[j]));
end;
end;
end;
end;
for i := 1 to maxObjects do begin
if sy[i]+r[i] >= Image1.Height then begin
vx[i] := vx[i];
vy[i] := -k*vy[i] + g*T;
sy[i] := sy[i] + vy[i]*T;
sx[i] := sx[i] + vx[i]*T;
if sy[i] + r[i] > Image1.Height then begin
sy[i] := Image1.Height - r[i];
end;
with Image1.Canvas do begin
//und das hier auch
//Rectangle(0,0,Image1.Width, Image1.Height);
Ellipse(ceil(sx[i]-r[i]),ceil(sy[i]-r[i]), ceil(sx[i]+r[i]), ceil(sy[i]+r[i]));
end;
end;
end;
end;
Dieser Beitrag ist für Jugendliche unter 18 Jahren nicht geeignet.
|
|
Zitat
|