Erittäin yksinkertainen ristinolla-peli.
Tarvii Timerit 1 ja 2 joille intervalliksi esim. 1.
Lisäksi tarvitaan Textbox nimeltä "kumpi" (ilman lainausmerkkejä).
Sitten vielä pitää tehdä 9 commandbuttonia tyyliin:
+-----------+ |n11|n12|n13| +-----------+ |n21|n22|n23| +-----------+ |n31|n32|n33| +-----------+
Jos ei jaksa kirjoittaa, niin lähdekoodin vb:n muodossa löytää osoitteesta http://koti.mbnet.fi/heikki_m/ristinolla_src.zip
exen voi ladata:
http://koti.mbnet.fi/~zombipro/download/Ristinolla.zip
Private Sub Form_Load() vuoro = 1 End Sub Private Sub n11_Click() If vuoro = 1 Then If Not n11.Caption = "X" And Not n11.Caption = "O" Then n11.Caption = "X" vuoro = 2 End If ElseIf vuoro = 2 Then If Not n11.Caption = "X" And Not n11.Caption = "O" Then n11.Caption = "O" vuoro = 1 End If End If End Sub Private Sub n12_Click() If vuoro = 1 Then If Not n12.Caption = "X" And Not n12.Caption = "O" Then n12.Caption = "X" vuoro = 2 End If ElseIf vuoro = 2 Then If Not n12.Caption = "X" And Not n12.Caption = "O" Then n12.Caption = "O" vuoro = 1 End If End If End Sub Private Sub n13_Click() If vuoro = 1 Then If Not n13.Caption = "X" And Not n13.Caption = "O" Then n13.Caption = "X" vuoro = 2 End If ElseIf vuoro = 2 Then If Not n13.Caption = "X" And Not n13.Caption = "O" Then n13.Caption = "O" vuoro = 1 End If End If End Sub Private Sub n21_Click() If vuoro = 1 Then If Not n21.Caption = "X" And Not n21.Caption = "O" Then n21.Caption = "X" vuoro = 2 End If ElseIf vuoro = 2 Then If Not n21.Caption = "X" And Not n21.Caption = "O" Then n21.Caption = "O" vuoro = 1 End If End If End Sub Private Sub n22_Click() If vuoro = 1 Then If Not n22.Caption = "X" And Not n22.Caption = "O" Then n22.Caption = "X" vuoro = 2 End If ElseIf vuoro = 2 Then If Not n22.Caption = "X" And Not n22.Caption = "O" Then n22.Caption = "O" vuoro = 1 End If End If End Sub Private Sub n23_Click() If vuoro = 1 Then If Not n23.Caption = "X" And Not n23.Caption = "O" Then n23.Caption = "X" vuoro = 2 End If ElseIf vuoro = 2 Then If Not n23.Caption = "X" And Not n23.Caption = "O" Then n23.Caption = "O" vuoro = 1 End If End If End Sub Private Sub n31_Click() If vuoro = 1 Then If Not n31.Caption = "X" And Not n31.Caption = "O" Then n31.Caption = "X" vuoro = 2 End If ElseIf vuoro = 2 Then If Not n31.Caption = "X" And Not n31.Caption = "O" Then n31.Caption = "O" vuoro = 1 End If End If End Sub Private Sub n32_Click() If vuoro = 1 Then If Not n32.Caption = "X" And Not n32.Caption = "O" Then n32.Caption = "X" vuoro = 2 End If ElseIf vuoro = 2 Then If Not n32.Caption = "X" And Not n32.Caption = "O" Then n32.Caption = "O" vuoro = 1 End If End If End Sub Private Sub n33_Click() If vuoro = 1 Then If Not n33.Caption = "X" And Not n33.Caption = "O" Then n33.Caption = "X" vuoro = 2 End If ElseIf vuoro = 2 Then If Not n33.Caption = "X" And Not n33.Caption = "O" Then n33.Caption = "O" vuoro = 1 End If End If End Sub Private Sub Timer2_Timer() 'TARKISTETAAN VOITTAJA. If n11.Caption = "X" And n12.Caption = "X" And n13.Caption = "X" Then MsgBox "X VOITTI!!!!!!" End ElseIf n11.Caption = "O" And n12.Caption = "O" And n13.Caption = "=" Then MsgBox "O VOITTI!!!!!!" End ElseIf n11.Caption = "X" And n21.Caption = "X" And n31.Caption = "X" Then MsgBox "X VOITTI!!!!!!" End ElseIf n11.Caption = "O" And n21.Caption = "O" And n31.Caption = "O" Then MsgBox "O VOITTI!!!!!!" End ElseIf n21.Caption = "X" And n22.Caption = "X" And n23.Caption = "X" Then MsgBox "X VOITTI!!!!!!" End ElseIf n21.Caption = "O" And n22.Caption = "O" And n23.Caption = "O" Then MsgBox "O VOITTI!!!!!!" End ElseIf n31.Caption = "X" And n32.Caption = "X" And n33.Caption = "X" Then MsgBox "X VOITTI!!!!!!" End ElseIf n31.Caption = "O" And n32.Caption = "O" And n33.Caption = "O" Then MsgBox "O VOITTI!!!!!!" End ElseIf n11.Caption = "X" And n22.Caption = "X" And n33.Caption = "X" Then MsgBox "X VOITTI!!!!!!" End ElseIf n11.Caption = "O" And n22.Caption = "O" And n33.Caption = "O" Then MsgBox "O VOITTI!!!!!!" End ElseIf n31.Caption = "X" And n22.Caption = "X" And n13.Caption = "X" Then MsgBox "X VOITTI!!!!!!" End ElseIf n31.Caption = "O" And n22.Caption = "O" And n13.Caption = "O" Then MsgBox "O VOITTI!!!!!!" End ElseIf n12.Caption = "X" And n22.Caption = "X" And n32.Caption = "X" Then MsgBox "X VOITTI!!!!!!" ElseIf n12.Caption = "O" And n22.Caption = "O" And n32.Caption = "O" Then MsgBox "O VOITTI!!!!!!" End ElseIf n13.Caption = "X" And n23.Caption = "X" And n33.Caption = "X" Then MsgBox "X VOITTI!!!!!!" End ElseIf n13.Caption = "O" And n23.Caption = "O" And n33.Caption = "O" Then MsgBox "O VOITTI!!!!!!" End End If End Sub Private Sub Timer1_Timer() kumpi.Text = vuoro End Sub
Okei.. ois ehkä voinu toteuttaa kätevämmi.. en tie...
Ilmoitelkaa bugeista...
Aihe on jo aika vanha, joten et voi enää vastata siihen.