![]() |
Re: Mastermind
sind aber immer noch 500 kB.... lass doch mal zumindest den _history ordner weg.
|
Re: Mastermind
Liste der Anhänge anzeigen (Anzahl: 1)
so dann noch mal die neue Version mit nur dem nötigsten hoffe ich habe nix vergessen
also noch mal hat jemand eine idee, wie man den code ändern könnte beispielsweise so ,dass man nicht jedes shape einzeln ansprechen mus??? |
Re: Mastermind
Zitat:
|
Re: Mastermind
moin,
ich habe mir mal deinen Source angeguckt und festgestellt, das du wirklich jede Kombination manuell abfragst.
Delphi-Quellcode:
Der obere Teil lässt sich mit einer Schleife wesentlich komfortabler lösen.
if (shape1.brush.color = clwhite) or (shape2.Brush.Color = clwhite) or (shape3.Brush.Color = clwhite) or (shape4.Brush.Color = clwhite) then showmessage ('Weiß ist keine Farbe. Bitte alle ausfüllen!!!') else
begin button1.Enabled := false; button2.Enabled := true; if shape1.brush.color = clmaroon then Farbe[1] := 1 else if shape1.brush.Color = clgreen then Farbe[1] := 2 else if shape1.brush.Color = clnavy then Farbe[1] := 3 else if shape1.brush.Color = clyellow then Farbe[1] := 4 else if shape1.brush.Color = clteal then Farbe[1] := 5 else if shape1.brush.Color = clpurple then Farbe[1] := 6; if shape2.brush.color = clmaroon then Farbe[2] := 1 else if shape2.brush.Color = clgreen then Farbe[2] := 2 else if shape2.brush.Color = clnavy then Farbe[2] := 3 else if shape2.brush.Color = clyellow then Farbe[2] := 4 else if shape2.brush.Color = clteal then Farbe[2] := 5 else if shape2.brush.Color = clpurple then Farbe[2] := 6; if shape3.brush.color = clmaroon then Farbe[3] := 1 else if shape3.brush.Color = clgreen then Farbe du hier eine Schleif[3] := 2 else if shape3.brush.Color = clnavy then Farbe[3] := 3 else if shape3.brush.Color = clyellow then Farbe[3] := 4 else if shape3.brush.Color = clteal then Farbe[3] := 5 else if shape3.brush.Color = clpurple then Farbe[1] := 6; if shape4.brush.color = clmaroon then Farbe[4] := 1 else if shape4.brush.Color = clgreen then Farbe[4] := 2 else if shape4.brush.Color = clnavy then Farbe[4] := 3 else if shape4.brush.Color = clyellow then Farbe[4] := 4 else if shape4.brush.Color = clteal then Farbe[4] := 5 else if shape4.brush.Color = clpurple then Farbe[4] := 6 ; activ := 2; senddata; Wobei ich hier nicht den Farbcode erfragen würde, sondern einfach nur eine simple Nummer. Du hast 6 Farben, die sich in ihrer Reihenfolge nichtverändern, also könntest du genauso 6 Nummern den Farben zuweisen von 1 bis 6. In einem Array of TColor stehen dann die einzelnen Farben. Über den Index (Nummer von 1-6) erhälst du anschließend die Farbe aus dem Array of TColor. Die Shapes könnte man genauso gut dynamisch erstellen. Wenn ich mich nicht täusche, sind es etwa 80, die du schon zur Entwurfszeit erstellt hast. Noch eleganter wäre eine Klasse, aber das ist für den Anfang sicherlich zu heavy für dich. |
Re: Mastermind
jo das stimmt mit einer klasse wäre ich etwas überfordert aber eine schleife dürfte ich noch hinkriegen
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:55 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-2025 by Thomas Breitkreuz