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


كود :
Public Class Form1
Dim WithEvents _
a1 As New Button, a2 As New Button, a3 As New Button, _
a4 As New Button, a5 As New Button, a6 As New Button, _
a7 As New Button, a8 As New Button, a9 As New Button, ng As New Button
Dim player_1_turn As Boolean, game_over As Boolean
Dim MM%(9), i%, p%(1)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Const t1 = 10, t2 = 50, t3 = 90
With Me : .Height = (t2 - t1) * 5 : .Width = t2 + t3 + 5 : .Text = "Tic Tac Toe" : End With
Call saada(a1, t1, t1) : Call saada(a2, t2, t1) : Call saada(a3, t3, t1)
Call saada(a4, t1, t2) : Call saada(a5, t2, t2) : Call saada(a6, t3, t2)
Call saada(a7, t1, t3) : Call saada(a8, t2, t3) : Call saada(a9, t3, t3)
Call saada(ng, t1, 130, 115, 30, "New game")
End Sub
Private Sub saada(ByVal asi As System.Object, ByVal v%, ByVal p%, _
Optional ByVal w% = 35, Optional ByVal h% = 35, Optional ByVal t$ = "[ ]")
Me.Controls.Add(asi) : i += 1
With asi
.left = v : .width = w : .tag = i
.top = p : .height = h : .text = t
End With
End Sub
Private Sub vajuta(ByVal asi As System.Object, ByVal e As System.EventArgs) _
Handles a1.Click, a2.Click, a3.Click, a4.Click, a5.Click, a6.Click, a7.Click, a8.Click, a9.Click
If game_over = False And Len(asi.text) = 4 Then
asi.text = IIf(player_1_turn = False, "X", "O")
MM(asi.tag) = 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 _
p(IIf(player_1_turn, 1, 0)) += 1 _
: MsgBox("Game over." & Chr(13) & "Player " & _
IIf(player_1_turn = True, 2, 1) & " is the winner!", _
MsgBoxStyle.Information, p(0) & " : " & p(1)) _
: game_over = True _
: Exit Sub
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
Private Sub newgame(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ng.Click
a1.Text = "[ ]" : a2.Text = "[ ]" : a3.Text = "[ ]" : game_over = False
a4.Text = "[ ]" : a5.Text = "[ ]" : a6.Text = "[ ]" : player_1_turn = False
a7.Text = "[ ]" : a8.Text = "[ ]" : a9.Text = "[ ]" : MM(0) = 0
For i As Integer = 1 To 9
MM(i) = 0
Next
End Sub
End Class
}}}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  كود بسيط لفحص الاتصال بالانترنت + تطبيق على الكود RaggiTech 0 537 17-10-12, 09:52 PM
آخر رد: RaggiTech
  (لعبة الذاكرة Memory Game) لتفهم التعامل مع مصفوفة الادوات RaggiTech 0 564 17-10-12, 09:05 PM
آخر رد: RaggiTech
  تطبيق منقول - لعمل زر update now RaggiTech 0 275 17-10-12, 05:08 PM
آخر رد: RaggiTech
  تطبيق منقول - عمل Drag &amp; Drop RaggiTech 0 207 17-10-12, 05:06 PM
آخر رد: RaggiTech

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


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