Autor Beitrag
ploRa
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59

Win XP
Delphi 6
BeitragVerfasst: Fr 04.03.05 20:22 
Hiho ihr.

Ich habe ein frage.

Kann man in Delphi 2 If-Schleifen gleichzeitig laufen lassen in einer Procedur ?

Bei mir läuft immer erst eine ab. Wenn diese fertig ist, fängt die 2te an.
Aber in meinem Spiel müssen 2-4 IF-Schleifen gleichzeitig ablaufen.

Bitte um Hilfe !
Hier mein Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
FOR i:=80 TO 700 DO BEGIN
Label6.top:=i;
if  ((label6.top + label6.height >= image5.top) and
     (label6.top <= image5.top+image5.height))
    and ((label6.left+label6.width>=image5.left) and
         (label6.left <= image5.left+image5.width))
    then
     label6.Destroy;
Delay(80);
end;

FOR i:=70 TO 700 DO BEGIN
Label7.top:=i;
if  ((label7.top + label7.height >= image5.top) and
     (label7.top <= image5.top+image5.height))
    and ((label7.left+label7.width>=image5.left) and
         (label7.left <= image5.left+image5.width))
    then
     label7.Destroy;
Delay(60);
end;


Das sind 2 Labels, die von oben herunter fallen.
Aber beide Labels sollen gleichzeitig unterschiedlich schnell fallen.


Bitte verständlich schreiben bin ein Delphi anfänger :)
Vielan Dank im vorraus.

Moderiert von user profile iconAXMD: Code- durch Delphi-Tags ersetzt.
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Fr 04.03.05 20:24 
Du könntest Threads verwenden oder - als Anfänger - zwei Timer mit unterschiedlichem "Interval" nehmen

AXMD
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Fr 04.03.05 20:26 
:twisted: gleich werden sich die geier hier auf die "IF-SCHLEIFE" stürzen.... ich bin der erste *fg*

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
ploRa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59

Win XP
Delphi 6
BeitragVerfasst: Fr 04.03.05 20:26 
ja das würde ja funktionieren aber die schleifen werden tortzdem einzelnt abgelaufen. Es geht mir eher darum das mehrere If schleifen gleichzeitig ablaufen können
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 04.03.05 20:27 
btw: Das sind For-Schleifen. :wink:
EDIT: Mist zu langsam.
ploRa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59

Win XP
Delphi 6
BeitragVerfasst: Fr 04.03.05 20:28 
ups ich meine ja FOR schleifen sorry !!
Egal meine frage bleibt trotzdem !
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 04.03.05 20:28 
Gleichzeitig geht nicht. Es sei denn, du hast einen Multiprozessor-Rechner und ein Entwicklungstool, dass diesen unterstützt.
ploRa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59

Win XP
Delphi 6
BeitragVerfasst: Fr 04.03.05 20:30 
wie bekomme ich denn meinen oben genannten code dazu, das die 2 Labels gleichzeitig in unterschiedlicher geschwindigkeit fallen ?
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 04.03.05 20:32 
Indem du Threads benutzt.
Bei Delphi ist eine Demo dabei mit 3 Sortierverfahren, die "gleichzeitig" ablaufen. Zumindest ist bei D5 die Demo dabei.
ploRa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59

Win XP
Delphi 6
BeitragVerfasst: Fr 04.03.05 20:32 
was sind threads ?
bin delphi anfänger !
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Fr 04.03.05 20:40 
ploRa hat folgendes geschrieben:
was sind threads ?
bin delphi anfänger !


de.wikipedia.org/wiki/Thread

AXMD
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 04.03.05 20:40 
Guckst du hier

Ich suche dir gleich noch einen Link mit Tutorial raus ....
... und hier ist er schon.