الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

للمبرمجييييييييييييين.......

مغلق
بدأه العين بحر في 8 مارس 2002 · 1 رد · 712 مشاهدة · في لغة Ms Visual Basic 6 وما قبلها من إصدارات
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

ياليت احد يشرح لي الكود شرح مفصل .. هذا كود لعبة السيجا..

وياليت في اسرع وقت

Option Explicit

Dim myDB As Database

Dim myRS As Recordset

Dim SQLStr As String

Dim X1 As Integer, Y1 As Integer

Dim Filled(0 To 8) As Integer

Dim WhoseTile(0 To 8) As Integer

Dim WhoseTurn As Integer, OtherTurn As Integer, WhoWin As Integer

Dim i As Integer, Tile As Integer

Dim BlinkIndicator As Integer

Dim AllFilled As Boolean, GotWinner As Boolean

Dim WinScore(0 To 1) As Integer, LoseScore(0 To 1) As Integer, DrawScore As Integer

Private Sub cmdQuit_Click()

End

End Sub

Private Sub ResetBoard()

Me.Picture1.PaintPicture Graphic.Tile(2).Picture, 24, 12, , , , , , , vbSrcCopy

Me.Picture1.PaintPicture Graphic.Tile(2).Picture, 77, 12, , , , , , , vbSrcCopy

Me.Picture1.PaintPicture Graphic.Tile(2).Picture, 136, 12, , , , , , , vbSrcCopy

Me.Picture1.PaintPicture Graphic.Tile(2).Picture, 24, 70, , , , , , , vbSrcCopy

Me.Picture1.PaintPicture Graphic.Tile(2).Picture, 77, 70, , , , , , , vbSrcCopy

Me.Picture1.PaintPicture Graphic.Tile(2).Picture, 136, 70, , , , , , , vbSrcCopy

Me.Picture1.PaintPicture Graphic.Tile(2).Picture, 24, 130, , , , , , , vbSrcCopy

Me.Picture1.PaintPicture Graphic.Tile(2).Picture, 77, 130, , , , , , , vbSrcCopy

Me.Picture1.PaintPicture Graphic.Tile(2).Picture, 136, 130, , , , , , , vbSrcCopy

For i = 0 To 8

Filled(i) = 0

WhoseTile(i) = -1

Next

WhoWin = -1

WhoseTurn = OtherTurn

BlinkIndicator = 0

Timer1.Enabled = True

End Sub

Private Sub cmdReset_Click()

Call ResetBoard

SQLStr = "UPDATE Scores SET P1W = 0, P1L = 0, Draw = 0, P2W = 0, P2L = 0"

myDB.Execute (SQLStr)

For i = 0 To 1

Win= 0

Lose= 0

Draw= 0

Next

WhoseTurn = 0

OtherTurn = 1

End Sub

Private Sub Form_Load()

Set myDB = OpenDatabase(App.Path + "WooDyzTTT.mdb")

For i = 0 To 8

Filled= 0

WhoseTile= -1

Next

Call GetWinnerScore

Call GetDrawScore

For i = 0 To 1

Win= WinScore(i)

Lose= LoseScore(i)

Draw= DrawScore

Next

WhoseTurn = 0

OtherTurn = 1

WhoWin = -1

BlinkIndicator = 0

End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

If (X >= 24) And (X <= 64) And (Y >= 12) And (Y <= 60) Then

X1 = 24

Y1 = 12

Tile = 0

ElseIf (X >= 77) And (X <= 124) And (Y >= 12) And (Y <= 60) Then

X1 = 77

Y1 = 12

Tile = 1

ElseIf (X >= 136) And (X <= 179) And (Y >= 12) And (Y <= 60) Then

X1 = 136

Y1 = 12

Tile = 2

ElseIf (X >= 24) And (X <= 64) And (Y >= 70) And (Y <= 120) Then

X1 = 24

Y1 = 70

Tile = 3

ElseIf (X >= 77) And (X <= 124) And (Y >= 70) And (Y <= 120) Then

X1 = 77

Y1 = 70

Tile = 4

ElseIf (X >= 136) And (X <= 179) And (Y >= 70) And (Y <= 120) Then

X1 = 136

Y1 = 70

Tile = 5

ElseIf (X >= 24) And (X <= 64) And (Y >= 130) And (Y <= 180) Then

X1 = 24

Y1 = 130

Tile = 6

ElseIf (X >= 77) And (X <= 124) And (Y >= 130) And (Y <= 180) Then

X1 = 77

Y1 = 130

Tile = 7

ElseIf (X >= 136) And (X <= 179) And (Y >= 130) And (Y <= 180) Then

X1 = 136

Y1 = 130

Tile = 8

End If

If Filled(Tile) <> 1 Then

Me.Picture1.PaintPicture Graphic.Tile(WhoseTurn).Picture, X1, Y1, , , , , , , vbSrcCopy

WhoseTile(Tile) = WhoseTurn

Filled(Tile) = 1

AllFilled = True

For i = 0 To 8

If Filled(i) = 0 Then _

AllFilled = False

Next

GotWinner = False

If WhoseTile(0) = WhoseTurn Then

If (WhoseTile(1) = WhoseTurn And WhoseTile(2) = WhoseTurn) Or (WhoseTile(3) = WhoseTurn And WhoseTile(6) = WhoseTurn) Or (WhoseTile(4) = WhoseTurn And WhoseTile(8) = WhoseTurn) Then _

GotWinner = True

End If

If GotWinner = False Then

If WhoseTile(1) = WhoseTurn Then

If (WhoseTile(4) = WhoseTurn And WhoseTile(7) = WhoseTurn) Then _

GotWinner = True

End If

End If

If GotWinner = False Then

If WhoseTile(2) = WhoseTurn Then

If (WhoseTile(4) = WhoseTurn And WhoseTile(6) = WhoseTurn) Or (WhoseTile(5) = WhoseTurn And WhoseTile(8) = WhoseTurn) Then _

GotWinner = True

End If

End If

If GotWinner = False Then

If WhoseTile(3) = WhoseTurn Then

If (WhoseTile(4) = WhoseTurn And WhoseTile(5) = WhoseTurn) Then _

GotWinner = True

End If

End If

If GotWinner = False Then

If WhoseTile(6) = WhoseTurn Then

If (WhoseTile(7) = WhoseTurn And WhoseTile(8) = WhoseTurn) Then _

GotWinner = True

End If

End If

If GotWinner = True Then

Win(WhoseTurn) = Trim(Str(Int(Win(WhoseTurn)) + 1))

Lose(OtherTurn) = Trim(Str(Int(Lose(OtherTurn)) + 1))

Timer1.Enabled = False

PlayerList(WhoseTurn).Visible = True

Call GetWinnerScore

SQLStr = "UPDATE Scores SET P" + Trim(Str(WhoseTurn + 1)) + "W = " + Trim(Str(WinScore(WhoseTurn) + 1)) + " , P" + Trim(Str(OtherTurn + 1)) + "L = " + Trim(Str(LoseScore(OtherTurn) + 1))

myDB.Execute (SQLStr)

MsgBox "Player " & Trim(Str(WhoseTurn + 1)) + " won the game.", vbOKOnly + vbInformation, "Winner"

Call ResetBoard

ElseIf AllFilled = True Then

Draw(WhoseTurn) = Trim(Str(Int(Draw(WhoseTurn)) + 1))

Draw(OtherTurn) = Trim(Str(Int(Draw(OtherTurn)) + 1))

Timer1.Enabled = False

Call GetDrawScore

SQLStr = "UPDATE Scores Set Draw = " + Trim(Str(DrawScore + 1))

myDB.Execute (SQLStr)

PlayerList(WhoseTurn).Visible = True

MsgBox "It's a draw game.", vbOKOnly + vbInformation, "Draw Game"

Call ResetBoard

Else

Timer1.Enabled = False

PlayerList(WhoseTurn).Visible = True

BlinkIndicator = 0

If WhoseTurn = 0 Then

WhoseTurn = 1

OtherTurn = 0

Else

WhoseTurn = 0

OtherTurn = 1

End If

Timer1.Enabled = True

End If

End If

End Sub

Private Sub Timer1_Timer()

If BlinkIndicator = 0 Then

PlayerList(WhoseTurn).Visible = True

BlinkIndicator = 1

Else

PlayerList(WhoseTurn).Visible = False

BlinkIndicator = 0

End If

End Sub

Public Sub GetWinnerScore()

SQLStr = "SELECT * FROM Scores"

Set myRS = myDB.OpenRecordset(SQLStr)

WinScore(0) = myRS.Fields("P1W")

WinScore(1) = myRS.Fields("P2W")

LoseScore(0) = myRS.Fields("P1L")

LoseScore(1) = myRS.Fields("P2L")

myRS.Close

Set myRS = Nothing

End Sub

Public Sub GetDrawScore()

SQLStr = "SELECT * FROM Scores"

Set myRS = myDB.OpenRecordset(SQLStr)

DrawScore = myRS.Fields("Draw")

myRS.Close

Set myRS = Nothing

End Sub

#2

هذا الكود لاينفع وناقص فيجب ان تقوم بارسال المشروع كاملا حتى يقوم احد بشرح اي شيء لك

جديد مدونتي الشخصية http://www.badwi.com

ادعو لنا بظاهر الغيب

MyBooksExchange.jpg

هذا الموضوع مغلق.

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…