Gra Kółko i Krzy?żyk :-)

0

Hej! {brawo}

Tak sobie z nudów zacząłem pisać Kółko i Krzyżyk :D i mam problemik (pytanie) hmm... .
Mam procedurę którą sprawdza wygraną:

procedure TForm1.SprawdzKtoWygral;
begin
if (x1.Caption = 'X') and (x2.Caption = 'X') and
(x3.Caption = 'X') or (x1.Caption = 'O') and
(x2.Caption = 'O') and (x3.Caption = 'O') then
Wygrana;

if (x4.Caption = 'X') and (x5.Caption = 'X') and
(x6.Caption = 'X') or (x4.Caption = 'O') and
(x5.Caption = 'O') and (x6.Caption = 'O') then
Wygrana;

if (x7.Caption = 'X') and (x8.Caption = 'X') and
(x9.Caption = 'X') or (x7.Caption = 'O') and
(x8.Caption = 'O') and (x9.Caption = 'O') then
Wygrana;

if (x1.Caption = 'X') and (x4.Caption = 'X') and
(x7.Caption = 'X') or (x1.Caption = 'O') and
(x4.Caption = 'O') and (x7.Caption = 'O') then
Wygrana;

if (x2.Caption = 'X') and (x5.Caption = 'X') and
(x8.Caption = 'X') or (x2.Caption = 'O') and
(x5.Caption = 'O') and (x8.Caption = 'O') then
Wygrana;

if (x3.Caption = 'X') and (x6.Caption = 'X') and
(x9.Caption = 'X') or (x3.Caption = 'O') and
(x6.Caption = 'O') and (x9.Caption = 'O') then
Wygrana;

if (x1.Caption = 'X') and (x5.Caption = 'X') and
(x9.Caption = 'X') or (x1.Caption = 'O') and
(x5.Caption = 'O') and (x9.Caption = 'O') then
Wygrana;

if (x3.Caption = 'X') and (x5.Caption = 'X') and
(x7.Caption = 'X') or (x3.Caption = 'O') and
(x5.Caption = 'O') and (x7.Caption = 'O') then
Wygrana;

end;

Przyciski są nazwane kolejno:

x1 x2 x3
x4 x5 x6
x7 x8 x9

I co trzeba dopisać do wygranej aby odpowiednia wygrana linia się pokolorowała na czerowno. Próbowałem swoich metod ale mi nie wychodziło.
Jak możecie to pomóżcie proszę {browar}
Pozdrawiam :-)

0

Mozesz narysowac linie, ktora zakresli wygrana:

procedure TForm1.SprawdzKtoWygral;
begin
if (x1.Caption = 'X') and (x2.Caption = 'X') and
(x3.Caption = 'X') or (x1.Caption = 'O') and
(x2.Caption = 'O') and (x3.Caption = 'O') then
begin
with Canvas do
begin
MoveTo(10,10);
LineTo(200,200);
end;
Wygrana;
end;
(...)
end;

0

A skad sie wzielo ;( to nie wiem hmm... :D

0

A co to tak płacze w tym kodzie??? D:D--You may say I am dreamer...

1 użytkowników online, w tym zalogowanych: 0, gości: 1