AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Timer.Interval<1

Ein Thema von Martin.Ghosts · begonnen am 8. Jun 2006 · letzter Beitrag vom 9. Jun 2006
 
Martin.Ghosts

Registriert seit: 9. Dez 2005
54 Beiträge
 
Delphi 7 Personal
 
#11

Re: Timer.Interval<1

  Alt 8. Jun 2006, 22:53
Zitat:
Teste doch einfach vorm Verschieben, ob's drüber hinaus geht und verschiebe nach der Abfrage.
(zu Matze) Klar, das könnte man machen. Jedoch wird dann die Wand sehr warscheinlich nicht berührt.

(zu SirThornberry) Hier mal mein Quelltext:
Delphi-Quellcode:
var
  Form1: TForm1;
  x, y: Integer;

implementation

{$R *.dfm}

procedure TForm1.Move;
begin
  Form1.Shape1.Left:= Form1.Shape1.Left + (x);
  Form1.Shape1.Top:= Form1.Shape1.Top + (y);
  if (Form1.Shape1.Left <= 0) then
    x:= (-1) * x;
  if (Form1.Shape1.Top <= 0) then
    y:= (-1) * y;
  if ((Form1.Shape1.Left + Form1.Shape1.Width) >= Form1.Width) then
    x:= (-1) * x;
  if ((Form1.Shape1.Top + Form1.Shape1.Height) >= Form1.Height) then
    y:= (-1) * y;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  x:= -1;
  y:= -1;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Form1.Move;
end;

end.
Wenn ich dich richtig versehe meinst du es so:
Delphi-Quellcode:
var
  Form1: TForm1;
  x, y, count: Integer;

implementation

{$R *.dfm}

procedure TForm1.Move;
begin
  Form1.Shape1.Left:= Form1.Shape1.Left + (x);
  Form1.Shape1.Top:= Form1.Shape1.Top + (y);
  if (Form1.Shape1.Left <= 0) then
    x:= (-1) * x;
  if (Form1.Shape1.Top <= 0) then
    y:= (-1) * y;
  if ((Form1.Shape1.Left + Form1.Shape1.Width) >= Form1.Width) then
    x:= (-1) * x;
  if ((Form1.Shape1.Top + Form1.Shape1.Height) >= Form1.Height) then
    y:= (-1) * y;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  x:= -1;
  y:= -1;
  count:= 0;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  if (count = 25) then
    begin
      count:= 0;
      Form1.Move;
    end
  else
    count:= count + 1;
end;

end.
Dadurch bewegt sich der Ball jedoch nochmal deutlich langsamer.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:25 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz