Autor Beitrag
anti303
Hält's aus hier
Beiträge: 1



BeitragVerfasst: Do 14.02.08 11:31 
hio, ich hab ma ne frage, ich hab keine Ahnung bei Hangman wie man die Striche durch den Buchstaben ersetz...
[hab hier ma den Buchstaben "q"]

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.qButtonClick(Sender: TObject);
begin
for y:= 1 to laenge do
if wort[y] = 'Q' then strichlabel.Caption:= 'Q'//striche verschwinden und nur  qButton.enabled := false;                         der momentane buchstabe zu sehn
end;


vielen Dank im vorraus mfg anti

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
nagel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 708

Win7, Ubuntu 10.10

BeitragVerfasst: Do 14.02.08 11:46 
Hallo,

Suche in der Entwickler-Ecke HANGMAN
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Do 14.02.08 19:00 
Hi,

Ich habe vor kurzem einen im Prinzip fertigen Quelltext dazu gepostet:
www.delphi-forum.de/...i+Hangman_80672.html

@user profile iconnagel
nur funktioniert die Suche im Moment nicht :!:

Edit:
Im OnKeyPress der Form rateBuchstabe mit Char(Key) aufrufen.
Zu Stringverarbeitung, siehe r2c2.weingut-rehn.de...itung_mit_Delphi.htm

user profile iconHidden hat folgendes geschrieben:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
  private  //Felder
    FSuchWort,FAnzeige: String;
    FFehlerzahl: Integer;  //im onCreate auf 0 setzen!
  private
    //private-declarations
  public
    //public-declarations
  end;

implementation

{$R *.dfm}  //Die von jaenicke angesprochene Zeile.

  procedure wortEinlesen(const pWort: String);
  var
    Index1: Integer;
  begin
    if length(pWort) <> 0 then begin
      FSuchWort := AnsiUpperCase(pWort);
      FAnzeige := '';
      for Index1 := 1 to length(FSuchWort) do
        FAnzeige := FAnzeige + '_';  //ich steh' im mom aufm Schlauch, das ist extrem schlecht so!!!
                                     //siehe dazu ein Tutorial über Strings, hier wird bei jedem Durchlauf ein neuer String erzeugt.
    end;
  end;

  procedure rateBuchstabe(pBuchstabe: Char);
  var
    Index1: Integer;
  begin
    if Pos(AnsiUpperCase(pBuchstabe),FSuchWort) = 0 then
      inc(Fehlerzahl);  //eventuell mehr zeichnen hier
    else begin
      for Index1 := 1 to length(FSuchwort) do begin
        if AnsiUpperCase(pBuchstabe) = AnsiUpperCase(FSuchwort[Index1]) then begin
          Delete(FAnzeige,Index1,1);
          Insert(pBuchstabe,FAnzeige,Index1);
        end;
      end;
    end;
  end;



Edit2: und wenn AnsiUpperCase(FAnzeige) = FSuchWort ist, hast du das Wort erraten.

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 14.02.08 19:15 
Moin!

user profile iconHidden hat folgendes geschrieben:
@user profile iconnagel
nur funktioniert die Suche im Moment nicht :!:
Grad getestet, geht einwandfrei, die Suche. :nixweiss:

cu
Narses

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

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Do 14.02.08 19:20 
user profile iconNarses hat folgendes geschrieben:
Moin!

user profile iconHidden hat folgendes geschrieben:
@user profile iconnagel
nur funktioniert die Suche im Moment nicht :!:
Grad getestet, geht einwandfrei, die Suche. :nixweiss:

Allgemeine Felder hat folgendes geschrieben:
Could not insert search results

Dachte das Problem bekämen alle... :nixweiss:

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)