Autor Beitrag
Lena00
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65
Erhaltene Danke: 4



BeitragVerfasst: Di 28.11.17 19:28 
Hi! Möchte für mein Spiel eine Art Bestenliste/Score erstellen, der nur für einmal starten/kompilieren "gespeichert" ist. Im Anhang ist mein bisheriger Quelltext, wobei a1,a2,a3 & a4 die Plätze 1,2,3,& 4 darstellen und Punkte die erreichten Punkte, bei denen die höchsten natürlich Platz eins sind. Bei gleicher Punktzahl soll auch der Platz "danach" belegt werden, da man ja zum Beispiel Platz 2 nicht überbietet aber jedoch Platz 3 trotzdem...
Hoffe auf Hilfe! :D

Moderiert von user profile iconNarses: Titel erweitert
Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Di 28.11.2017 um 20:09
Einloggen, um Attachments anzusehen!
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10181
Erhaltene Danke: 1254

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 28.11.17 19:36 
Moin!

Ein kleiner Tipp am Rande: du kannst den Quelltext hier auch direkt in den Beitrag einfügen, sogar hübsch formatiert, wenn du die Delphi-Tags drum rum setzt. :idea: Das macht es deutlich einfacher deine Beiträge zu lesen, weil man nicht immer erst das Bild runterladen muss. ;)

Was du möchtest, ist eine Liste sortieren. Habt ihr im Unterricht sowas schon behandelt? :lupe:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Lena00 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65
Erhaltene Danke: 4



BeitragVerfasst: Di 28.11.17 19:44 
Vielen Dank für den Tipp! :wink:
Nein haben wir bisher nicht, aber etwas das im Unterricht noch keine Rolle spielte ist sogar verlangt! Also etwas "Neues".
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10181
Erhaltene Danke: 1254

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 28.11.17 19:51 
Moin!

Aha, na dann. :? Habt ihr denn schon Felder (array) und Schleifen (for, repeat, while) besprochen oder hast du dich eventuell schon selbst damit beschäftigt? Man kann eine 4-Platz-Liste zwar auch mit statischen if-Anweisungen „sortieren“, aber das grenzt schon an Folter... :zwinker:

Kurz: das könnte (noch) etwas schwierig für dich sein. Sicher, dass du das angehen willst? :nixweiss:

cu
Narses

PS: wo ich so drüber nachdenke, es gäbe natürlich auch eine halbgemogelte Variante über die VCL-Komponenten... :idea:

_________________
There are 10 types of people - those who understand binary and those who don´t.
Lena00 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65
Erhaltene Danke: 4



BeitragVerfasst: Di 28.11.17 19:59 
Ja Schleifen und Arrays waren schon einmal Thema! Dachte bloß das wäre so die einfachste Möglichkeit, aber damit lag ich wohl dann falsch! :D
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10181
Erhaltene Danke: 1254

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 28.11.17 20:09 
Moin!

Also, was darf es sein: die Variante über ein VCL-Control, dass das Sortieren für dich übernimmt oder selbst sortieren?

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Lena00 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65
Erhaltene Danke: 4



BeitragVerfasst: Di 28.11.17 20:18 
Gute Frage :nixweiss:
Aber VCL-Control hört sich gut an wenn es verständlich ist :)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10181
Erhaltene Danke: 1254

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 28.11.17 20:28 
Moin!

Dann probieren wir das mal. :zustimm:

Zieh doch bitte mal eine ListBox auf das Formular. Im Objekt-Inspektor stellst du die Eigenschaft .Sorted auf TRUE. Dann legst du noch einen weiteren Button mit auf das Formular (nur zum Testen, der kommt später wieder raus). Doppelklick auf den Button, um den Ereignishandler zu öffnen, dann schreibst du da rein: Listbox1.Items.Add(IntToStr(Random(100));
Programm starten und ein paar mal auf den Test-Button klicken. Was passiert? :lupe:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Lena00 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65
Erhaltene Danke: 4



BeitragVerfasst: Di 28.11.17 20:41 
Hat soweit alles geklappt und es erscheinen nun für mich auf den ersten Blick wahllose Zahlen in der Box :)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10181
Erhaltene Danke: 1254

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 28.11.17 20:45 
Moin!

user profile iconLena00 hat folgendes geschrieben Zum zitierten Posting springen:
es erscheinen nun für mich auf den ersten Blick wahllose Zahlen in der Box :)
Schön. Die Zahlen sind tatsächlich „wahllos“, weil mit dem Random() Zufallszahlen erzeugt werden. :idea:

Wenn du statt der 100 mal nur 20 angibst (die Obergrenze für die Zufallszahlen), dann sollte sich nach ein paar Buttonklicks (ruhig mal so 20x klicken) was erkennen lassen. :lupe: Oder? :D

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Lena00 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65
Erhaltene Danke: 4



BeitragVerfasst: Di 28.11.17 20:53 
Es lässt sich erkennen, dass ausschließlich Zahlen von 0 bis 20 ausgegeben werden... :)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10181
Erhaltene Danke: 1254

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 28.11.17 20:57 
Moin!

Der war gut! :lol: OK, ich drücke mich offensichtlich nicht gut aus. Also: bitte 10x Zahlen einfügen und dann den Inhalt der Listbox hier reinstellen. ;) Bis gleich... :zustimm:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Lena00 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65
Erhaltene Danke: 4



BeitragVerfasst: Di 28.11.17 21:07 
Ich schreib die jetzt einfach mal fix so hier rein von oben nach unten: 11, 19, 2, 3, 4, 5, 6, 7, 8, 9
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10181
Erhaltene Danke: 1254

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 28.11.17 21:09 
Und dir fällt echt nix auf? ;)

_________________
There are 10 types of people - those who understand binary and those who don´t.
Lena00 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65
Erhaltene Danke: 4



BeitragVerfasst: Di 28.11.17 21:24 
Naja sie sind schon sortiert, wobei aber 11 und 19 aus der Reihe fallen
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10181
Erhaltene Danke: 1254

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 28.11.17 21:26 
Moin! (im wahrsten Sinne des Wortes :lol:)

Ich muss hier für „heute“ vertagen, weil es da, wo ich mich grade aufhalte, bereits mitten in der Nacht ist... :gaehn: Vielleicht kann ja einer der erfahreneren Helfer solange übernehmen. :zustimm:

@user profile iconLena00: wenn du nicht direkt drauf kommst, dann gib als Obergrenze 10, dann 100 und dann nochmal 1000 ein. Wird es dann klarer? :les: :think:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Symbroson
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 382
Erhaltene Danke: 67

Raspbian, Ubuntu, Win10
C, C++, Python, JavaScript, Lazarus, Delphi7, Casio Basic
BeitragVerfasst: Di 28.11.17 21:30 
Ein kleiner Tipp meinerseits: Schau dir nicht nur die Zahlen an, sondern die Ziffern - Stelle für Stelle ;)

_________________
most good programmers do programming not because they expect to get paid or get adulation by the public, but because it's fun to program. (Linus Torvalds)
Lena00 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65
Erhaltene Danke: 4



BeitragVerfasst: Di 28.11.17 21:37 
:idea: :idea: :idea: :idea:
Oh man :D danke füt den Tipp, wie konnte man das übersehen :lol:
Lena00 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65
Erhaltene Danke: 4



BeitragVerfasst: Di 28.11.17 21:57 
So schonmal gecheckt!
Wie verbinde ich das jetzt mit der Punktzahl aus einem Editfeld und was mache ich bei Punkten über 100? Ist nämlich auch möglich :lol:
Symbroson
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 382
Erhaltene Danke: 67

Raspbian, Ubuntu, Win10
C, C++, Python, JavaScript, Lazarus, Delphi7, Casio Basic
BeitragVerfasst: Di 28.11.17 21:58 
Moment ich glaube ich weiß jetzt worauf Narses hinaus wollte. kleinen Moment bitte :)
continue

_________________
most good programmers do programming not because they expect to get paid or get adulation by the public, but because it's fun to program. (Linus Torvalds)


Zuletzt bearbeitet von Symbroson am Di 28.11.17 22:38, insgesamt 1-mal bearbeitet