Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#4

Re: Mein Spiel -> CPU Auslastung 100%

  Alt 12. Sep 2005, 12:45
*g* Luckie wie alle ihn kennen

da es ja die Auslastung dauernd 100% ist kann es ja nur an Code liegen der dauernd ausgeführt wird.
Also :
Delphi-Quellcode:
procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
  DXInput1.Update;
  DXSpriteEngine1.Move(1);
  DXDraw1.Surface.Fill(0);
  DXSpriteEngine1.Draw;
  DXDraw1.Flip;
end;
oder

Delphi-Quellcode:
procedure TSpieler.DoMove(MoveCount : Integer);
var Strecke : Double;
    xWeg,yWeg, xDiff,yDiff, Schritte : Double;
begin
inherited DoMove(MoveCount);
if (IsLeft in Form1.DXInput1.States) and (Move = false) then begin
  aX := Station.Links.X + (Station.Width/2);
  ay := Station.Links.y + (Station.Height/2);
  Move := true;
end;
 if (IsRight in Form1.DXInput1.States) and (Move = false)then begin
  aX := Station.Rechts.X + (Station.Width/2);
  ay := Station.Rechts.y + (Station.Height/2);
  Move := true;
end;

if Move = true then begin
  xWeg := Ax -x;
  yWeg := Ay -y;
  Strecke := Sqrt(Sqr(xWeg)+Sqr(yWeg));
  Schritte := Round(Strecke / 2);
  if Schritte = 0 then Schritte := 20;
  xDiff := xWeg / Schritte;
  yDiff := yWeg / Schritte;
  x := x + xDiff;
  y := y + yDiff;

  if (x = Ax) and (Ay = y) then Move := false;
end;
  Collision;
end;
Ansonsten wir bei mir nichts dauernd ausgeführt...

@ mbamler : Mh ok.. dann kann ichs wohl nicht ändern...
Michael
  Mit Zitat antworten Zitat