Hallo,
ich habe hier mal ein Spiel geschrieben als Schulaufgabe.
Alle Proceure festgelegt.
Es ist das bekannte 3 gewinnt Spiel auch TicTaeToe genannt.
-Wie definiere ich, dass wenn alle Felder( Buttons) angeklickt sind und keiner
procedure Gewinner
aktiviert? Dann ist nämlich unentschieden für Beiden.
(- Ich freue mich auch gerne über Verbesserungsvorschläge und Tipps für meinen Design usw.)
Hier mal mein Gewinnprocedure:
Delphi-Quellcode:
procedure TForm1.Gewinner;
begin
// ___________ Gewinnerdefinition___________ \\
// 1-2-3 \\
// 4-5-6 \\
// 7-8-9 \\
//Player 1 = O gewinnt!
// [Player Win 1.1] 1-2-3
if (Button1.caption='O') and (Button2.caption='O') and (Button3.caption='O') then
Form2.Show;
if (Button1.caption='O') and (Button2.caption='O') and (Button3.caption='O') then
Panel2.Caption:='gewonnen';
// [Player Win 1.2] 4-5-6
if (Button4.caption='O') and (Button5.caption='O') and (Button6.caption='O') then
Form2.Show;
if (Button4.caption='O') and (Button5.caption='O') and (Button6.caption='O') then
Panel2.Caption:='gewonnen';
// [Player Win 1.3] 7-8-9
if (Button7.caption='O') and (Button8.caption='O') and (Button9.caption='O') then
Form2.Show;
if (Button7.caption='O') and (Button8.caption='O') and (Button9.caption='O') then
Panel2.Caption:='gewonnen';
// [Player Win 1.4] 1-4-7
if (Button1.caption='O') and (Button4.caption='O') and (Button7.caption='O') then
Form2.Show;
if (Button1.caption='O') and (Button4.caption='O') and (Button7.caption='O') then
Panel2.Caption:='gewonnen';
// [Player Win 1.5] 2-5-8
if (Button2.caption='O') and (Button5.caption='O') and (Button8.caption='O') then
Form2.Show;
if (Button2.caption='O') and (Button5.caption='O') and (Button8.caption='O') then
Panel2.Caption:='gewonnen';
// [Player Win 1.6] 3-6-9
if (Button3.caption='O') and (Button6.caption='O') and (Button9.caption='O') then
Form2.Show;
if (Button3.caption='O') and (Button6.caption='O') and (Button9.caption='O') then
Panel2.Caption:='gewonnen';
// [Player Win 1.7] 1-5-9
if (Button1.caption='O') and (Button5.caption='O') and (Button9.caption='O') then
Form2.Show;
if (Button1.caption='O') and (Button5.caption='O') and (Button9.caption='O') then
Panel2.Caption:='gewonnen';
// [Player Win 1.8] 3-5-7
if (Button3.caption='O') and (Button5.caption='O') and (Button7.caption='O') then
Form2.Show;
if (Button3.caption='O') and (Button5.caption='O') and (Button7.caption='O') then
Panel2.Caption:='gewonnen';
//Player 2 = X gewinnt!
// [Player Win 2.1] 1-2-3
if (Button1.caption='X') and (Button2.caption='X') and (Button3.caption='X') then
Form3.Show;
if (Button1.caption='X') and (Button2.caption='X') and (Button3.caption='X') then
Panel2.Caption:='gewonnen';
// [Player Win 2.2] 4-5-6
if (Button4.caption='X') and (Button5.caption='X') and (Button6.caption='X') then
Form3.Show;
if (Button4.caption='X') and (Button5.caption='X') and (Button6.caption='X') then
Panel2.Caption:='gewonnen';
// [Player Win 2.3] 7-8-9
if (Button7.caption='X') and (Button8.caption='X') and (Button9.caption='X') then
Form3.Show;
if (Button7.caption='X') and (Button8.caption='X') and (Button9.caption='X') then
Panel2.Caption:='gewonnen';
// [Player Win 2.4] 1-4-7
if (Button1.caption='X') and (Button4.caption='X') and (Button7.caption='X') then
Form3.Show;
if (Button1.caption='X') and (Button4.caption='X') and (Button7.caption='X') then
Panel2.Caption:='gewonnen';
// [Player Win 2.5] 2-5-8
if (Button2.caption='X') and (Button5.caption='X') and (Button8.caption='X') then
Form3.Show;
if (Button2.caption='X') and (Button5.caption='X') and (Button8.caption='X') then
Panel2.Caption:='gewonnen';
// [Player Win 2.6] 3-6-9
if (Button3.caption='X') and (Button6.caption='X') and (Button9.caption='X') then
Form3.Show;
if (Button3.caption='X') and (Button6.caption='X') and (Button9.caption='X') then
Panel2.Caption:='gewonnen';
// [Player Win 2.7] 1-5-9
if (Button1.caption='X') and (Button5.caption='X') and (Button9.caption='X') then
Form3.Show;
if (Button1.caption='X') and (Button5.caption='X') and (Button9.caption='X') then
Panel2.Caption:='gewonnen';
// [Player Win 2.8] 3-5-7
if (Button3.caption='X') and (Button5.caption='X') and (Button7.caption='X') then
Form3.Show;
if (Button3.caption='X') and (Button5.caption='X') and (Button7.caption='X') then
Panel2.Caption:='gewonnen'
Danke