تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
تطبيق كامل منقول - لعبة Xo - 1
#1
كاتب الموضوع : AhmedEssawy


كود :
Dim WithEvents l_1 As Label, WithEvents l_2 As Label, WithEvents l_3 As Label
Dim WithEvents l_4 As Label, WithEvents l_5 As Label, WithEvents l_6 As Label
Dim WithEvents l_7 As Label, WithEvents l_8 As Label, WithEvents l_9 As Label
Dim WithEvents str As CommandButton
Dim player_1_turn As Boolean, MM(9) As Integer
Private Sub l_1_Click(): Call jagaja(1): End Sub
Private Sub l_2_Click(): Call jagaja(2): End Sub
Private Sub l_3_Click(): Call jagaja(3): End Sub
Private Sub l_4_Click(): Call jagaja(4): End Sub
Private Sub l_5_Click(): Call jagaja(5): End Sub
Private Sub l_6_Click(): Call jagaja(6): End Sub
Private Sub l_7_Click(): Call jagaja(7): End Sub
Private Sub l_8_Click(): Call jagaja(8): End Sub
Private Sub l_9_Click(): Call jagaja(9): End Sub
Private Sub str_Click()
Dim i As Integer
l_1.Caption = "[ ]": l_2.Caption = "[ ]": l_3.Caption = "[ ]": gameover = False
l_4.Caption = "[ ]": l_5.Caption = "[ ]": l_6.Caption = "[ ]": player_1_turn = False
l_7.Caption = "[ ]": l_8.Caption = "[ ]": l_9.Caption = "[ ]": MM(0) = 0

For i = 1 To 9
MM(i) = 0
Next i
End Sub

Private Sub Form_Load()
Const x_1 = 200, x_2 = 1200, x_3 = 2200, x_4 = 200, x_5 = "[ ]", x_6 = "Go", x_7 = 2600

Set l_1 = Me.Controls.Add("vb.Label", "l_1", Form1): Set l_2 = Me.Controls.Add("vb.Label", "l_2", Form1)
Set l_3 = Me.Controls.Add("vb.Label", "l_3", Form1): Set l_4 = Me.Controls.Add("vb.Label", "l_4", Form1)
Set l_5 = Me.Controls.Add("vb.Label", "l_5", Form1): Set l_6 = Me.Controls.Add("vb.Label", "l_6", Form1)
Set l_7 = Me.Controls.Add("vb.Label", "l_7", Form1): Set l_8 = Me.Controls.Add("vb.Label", "l_8", Form1)
Set l_9 = Me.Controls.Add("vb.label", "l_9", Form1): Set str = Me.Controls.Add("vb.CommandButton", "start", Form1)

With l_1: .Move x_1, x_1, x_4, x_4: .Caption = x_5: .Visible = True: End With
With l_2: .Move x_1, x_2, x_4, x_4: .Caption = x_5: .Visible = True: End With
With l_3: .Move x_1, x_3, x_4, x_4: .Caption = x_5: .Visible = True: End With
With l_4: .Move x_2, x_1, x_4, x_4: .Caption = x_5: .Visible = True: End With
With l_5: .Move x_2, x_2, x_4, x_4: .Caption = x_5: .Visible = True: End With
With l_6: .Move x_2, x_3, x_4, x_4: .Caption = x_5: .Visible = True: End With
With l_7: .Move x_3, x_1, x_4, x_4: .Caption = x_5: .Visible = True: End With
With l_8: .Move x_3, x_2, x_4, x_4: .Caption = x_5: .Visible = True: End With
With l_9: .Move x_3, x_3, x_4, x_4: .Caption = x_5: .Visible = True: End With
With str: .Move x_7, x_1, 600, 400: .Caption = x_6: .Visible = True: End With
With Me: .Height = 3000: .Width = 3500: .Caption = "Tic Tac Toe": End With
End Sub
Sub jagaja(nr)
If gameover = False And MM(nr) = 0 Then
Select Case nr
Case 1: l_1.Caption = IIf(player_1_turn = False, "X", "O")
Case 2: l_2.Caption = IIf(player_1_turn = False, "X", "O")
Case 3: l_3.Caption = IIf(player_1_turn = False, "X", "O")
Case 4: l_4.Caption = IIf(player_1_turn = False, "X", "O")
Case 5: l_5.Caption = IIf(player_1_turn = False, "X", "O")
Case 6: l_6.Caption = IIf(player_1_turn = False, "X", "O")
Case 7: l_7.Caption = IIf(player_1_turn = False, "X", "O")
Case 8: l_8.Caption = IIf(player_1_turn = False, "X", "O")
Case 9: l_9.Caption = IIf(player_1_turn = False, "X", "O")
End Select

MM(nr) = IIf(player_1_turn = False, 1, 2)

If MM(1) = MM(2) And MM(2) = MM(3) And MM(3) > 0 Or MM(1) = MM(4) And MM(4) = MM(7) And MM(7) > 0 Or _
MM(4) = MM(5) And MM(5) = MM(6) And MM(6) > 0 Or MM(2) = MM(5) And MM(5) = MM(8) And MM(8) > 0 Or _
MM(7) = MM(8) And MM(8) = MM(9) And MM(9) > 0 Or MM(3) = MM(6) And MM(6) = MM(9) And MM(9) > 0 Or _
MM(1) = MM(5) And MM(5) = MM(9) And MM(9) > 0 Or MM(7) = MM(5) And MM(5) = MM(3) And MM(3) > 0 Then _
MsgBox ("Game over." & Chr(13) & "Player " & IIf(player_1_turn = True, 2, 1) & " is the winner!"): game_over = True
If MM(0) < 8 Then MM(0) = MM(0) + 1: player_1_turn = Not player_1_turn Else MsgBox ("It's a draw"): game_over = True
End If
End Sub
المصدر :
http://www.dreamincode.net/code/snippet841.htm
}}}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  تطبيق منقول - آلة حاسبة بالكتابة المباشرة RaggiTech 0 330 17-10-12, 12:37 AM
آخر رد: RaggiTech
  تطبيق كامل منقول - قراءة وتعديل صورة Jpeg RaggiTech 0 438 17-10-12, 12:35 AM
آخر رد: RaggiTech

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم