AGB  ·  Datenschutz  ·  Impressum  







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

Programm vereinfachen

Ein Thema von len123 · begonnen am 3. Aug 2012 · letzter Beitrag vom 4. Aug 2012
 
len123

Registriert seit: 3. Aug 2012
6 Beiträge
 
#1

Programm vereinfachen

  Alt 3. Aug 2012, 20:03
Hey
Ich hab bastel grad an einem kleinen Tic Tac Toe-Spiel,
es besteht aus 9 labels, die ihre "caption" ändern, wen man auf sie klickt.
Ich muss noch anmerken das ich newbe in sachen Programmierung bin!
Das Programm guckt, nach jedem klick ob ein Spieler gewonnen hat,
dazu hab ich die Bedingungen bei jedem labelclick methode eingefügt.
Jetz ist meine Frage, da der Skript dadurch sehr lang wird, ob man das nicht irgend wie anders machen könnt
z.B. das man Bedingungen nur in eine methode packt die dann die nachguckt ob die Bedingung erfüllt ist.

Bedingung:
Code:
if (Label1.Caption='X') and (Label2.Caption='X') and (Label3.Caption='X') or
  (Label4.Caption='X') and (Label5.Caption='X')and (Label6.Caption='X') or
  (Label7.Caption='X') and (Label8.Caption='X')and (Label9.Caption='X') or
  (Label1.Caption='X') and (Label4.Caption='X')and (Label7.Caption='X') or
  (Label2.Caption='X') and (Label5.Caption='X')and (Label8.Caption='X') or
  (Label3.Caption='X') and (Label6.Caption='X')and (Label9.Caption='X') or
  (Label1.Caption='X') and (Label5.Caption='X')and (Label9.Caption='X') or
  (Label3.Caption='X') and (Label5.Caption='X')and (Label7.Caption='X')
  then
   begin
            Label11.Caption:= 'Spieler X hat gewonnen!';
   end;
   if (Label1.Caption='O') and (Label2.Caption='O') and (Label3.Caption='O') or
  (Label4.Caption='O') and (Label5.Caption='O')and (Label6.Caption='O') or
  (Label7.Caption='O') and (Label8.Caption='O')and (Label9.Caption='O') or
  (Label1.Caption='O') and (Label4.Caption='O')and (Label7.Caption='O') or
  (Label2.Caption='O') and (Label5.Caption='O')and (Label8.Caption='O') or
  (Label3.Caption='O') and (Label6.Caption='O')and (Label9.Caption='O') or
  (Label1.Caption='O') and (Label5.Caption='O')and (Label9.Caption='O') or
  (Label3.Caption='O') and (Label5.Caption='O')and (Label7.Caption='O')
  then
   begin
            Label11.Caption:= 'Spieler O hat gewonnen!';
   end;

Ich hoffe ihr versteht meine frage

gruß lenn
  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 06:34 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