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

بغيت حد يشرح هالكود الخاص بلعبة HungMan ..

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

السلام عليكم

عندي كود لعبة

HungMan

بس فيه اكواد ما فهمتها .. بلييز حد يشرح هم لي ..

Public Sub Form_Load()

Dim fso As New FileSystemObject

Dim strm As TextStream

Label18.Caption = login.user_name.Text

App.Title = " Hangman"

On Error GoTo A

Set strm = fso.OpenTextFile(App.Path & "\Settings", ForReading)

On Error Resume Next

Dim Item As ListItem

frmWords.lstWords.ColumnHeaders.Item(1).Width = frmWords.lstWords.Width - 1050

frmWords.lstWords.ColumnHeaders.Item(2).Width = 400

Do Until strm.AtEndOfStream

Set Item = frmWords.lstWords.ListItems.Add(, , strm.ReadLine)

Item.SubItems(1) = Len(Item.Text)

Loop

strm.Close

mnuStopGame_Click

Exit Sub

A:

Set strm = fso.CreateTextFile(App.Path & "\Settings", True)

strm.WriteLine "Interruption"

strm.WriteLine "BartNet"

strm.WriteLine "Complot"

strm.WriteLine "Computer"

strm.WriteLine "House"

strm.WriteLine "Bed"

strm.WriteLine "Human"

strm.WriteLine "Windows"

strm.Close

Dim File As File

Set File = fso.GetFile(App.Path & "\Settings")

File.Attributes = Hidden

Form_Load

**************

Private Sub cmdLetter_Click(Index As Integer)

Dim A As Integer

Dim Correct As Boolean

Correct = False

Do Until A = lblLetter.Count

If LCase(lblLetter(A).Tag) = LCase(cmdLetter(Index).Caption) Then

Correct = True

lblLetter(A).Caption = cmdLetter(Index).Caption

Else

End If

A = A + 1

Loop

If Correct = True Then

Dim B As Integer

Dim Wrong As Boolean

Wrong = False

Do Until B = lblLetter.Count

If LCase(lblLetter( B ).Tag) <> LCase(lblLetter( B ).Caption) Then Wrong = True

B = B + 1

Loop

If Wrong = False Then

MsgBox "You Have Won The Game.", vbOKOnly + vbInformation, "BartNet Hangman"

lblTimeTakenLastGame.Caption = lblTimeTakenThisGame.Caption

lblWrongGuessesLastGame.Caption = lblWrongGuessesThisGame.Caption

mnuStopGame_Click

Else

End If

Else

WrongGuesses = WrongGuesses + 1

lblWrongGuessesThisGame.Caption = "Wrong Guesses : " & WrongGuesses

Select Case WrongGuesses

Case 0

Case 1

Man(0).Visible = True

Case 2

Man(0).Visible = True

Man(1).Visible = True

Case 3

Man(0).Visible = True

Man(1).Visible = True

Man(2).Visible = True

Case 4

Man(0).Visible = True

Man(1).Visible = True

Man(2).Visible = True

Man(3).Visible = True

Case 5

Man(0).Visible = True

Man(1).Visible = True

Man(2).Visible = True

Man(3).Visible = True

Man(4).Visible = True

Case 6

Man(0).Visible = True

Man(1).Visible = True

Man(2).Visible = True

Man(3).Visible = True

Man(4).Visible = True

Man(5).Visible = True

Case 7

Man(0).Visible = True

Man(1).Visible = True

Man(2).Visible = True

Man(3).Visible = True

Man(4).Visible = True

Man(5).Visible = True

Shape.Visible = True

Case 8

Man(0).Visible = True

Man(1).Visible = True

Man(2).Visible = True

Man(3).Visible = True

Man(4).Visible = True

Man(5).Visible = True

Shape.Visible = True

Man(6).Visible = True

Case 9

Man(0).Visible = True

Man(1).Visible = True

Man(2).Visible = True

Man(3).Visible = True

Man(4).Visible = True

Man(5).Visible = True

Shape.Visible = True

Man(6).Visible = True

Man(7).Visible = True

Case 10

Man(0).Visible = True

Man(1).Visible = True

Man(2).Visible = True

Man(3).Visible = True

Man(4).Visible = True

Man(5).Visible = True

Shape.Visible = True

Man(6).Visible = True

Man(7).Visible = True

Man(8).Visible = True

Case 11

Man(0).Visible = True

Man(1).Visible = True

Man(2).Visible = True

Man(3).Visible = True

Man(4).Visible = True

Man(5).Visible = True

Shape.Visible = True

Man(6).Visible = True

Man(7).Visible = True

Man(8).Visible = True

Man(9).Visible = True

Case 12

Man(0).Visible = True

Man(1).Visible = True

Man(2).Visible = True

Man(3).Visible = True

Man(4).Visible = True

Man(5).Visible = True

Shape.Visible = True

Man(6).Visible = True

Man(7).Visible = True

Man(8).Visible = True

Man(9).Visible = True

Man(10).Visible = True

MsgBox "You Have Lost The Game", vbOKOnly + vbInformation, "BartNet Hangman"

mnuStopGame_Click

End Select

End If

cmdLetter(Index).Enabled = False

End Sub

**********

Private Sub mnuStartGame_Click()

Dim A As Integer

Do Until A = cmdLetter.Count

cmdLetter(A).Enabled = True

A = A + 1

Loop

Timer1.Enabled = True

WrongGuesses = 0

mnuStartGame.Enabled = False

mnuStopGame.Enabled = True

Dim Item As ListItem

Dim Items As ListItems

Dim B As Integer

Dim Word As String

Set Items = frmWords.lstWords.ListItems

Select Case Items.Count

Case 1 To 10

B = Round(Rnd * 10, 0)

If B = 0 Then B = 1

If B > Items.Count Then

mnuStartGame_Click

Exit Sub

Else

End If

Case 11 To 100

B = Round(Rnd * 100, 0)

If B > Items.Count Then

mnuStartGame_Click

Exit Sub

Else

End If

Case 101 To 1000

B = Round(Rnd * 1000, 0)

If B > Items.Count Then

mnuStartGame_Click

Exit Sub

Else

End If

End Select

Word = frmWords.lstWords.ListItems.Item( B ).Text

Select Case Len(Word)

Case 1

lblLetter(0).Caption = "& "

lblLetter(1).Caption = "-"

lblLetter(2).Caption = "-"

lblLetter(3).Caption = "-"

lblLetter(4).Caption = "-"

lblLetter(5).Caption = "-"

lblLetter(6).Caption = "-"

lblLetter(7).Caption = "-"

lblLetter(8).Caption = "-"

lblLetter(9).Caption = "-"

lblLetter(10).Caption = "-"

lblLetter(11).Caption = "-"

lblLetter(0).Tag = Word

Case 2

lblLetter(0).Caption = "& "

lblLetter(1).Caption = "& "

lblLetter(2).Caption = "-"

lblLetter(3).Caption = "-"

lblLetter(4).Caption = "-"

lblLetter(5).Caption = "-"

lblLetter(6).Caption = "-"

lblLetter(7).Caption = "-"

lblLetter(8).Caption = "-"

lblLetter(9).Caption = "-"

lblLetter(10).Caption = "-"

lblLetter(11).Caption = "-"

lblLetter(0).Tag = Mid(Word, 1, 1)

lblLetter(1).Tag = Mid(Word, 2, 1)

Case 3

lblLetter(0).Caption = "& "

lblLetter(1).Caption = "& "

lblLetter(2).Caption = "& "

lblLetter(3).Caption = "-"

lblLetter(4).Caption = "-"

lblLetter(5).Caption = "-"

lblLetter(6).Caption = "-"

lblLetter(7).Caption = "-"

lblLetter(8).Caption = "-"

lblLetter(9).Caption = "-"

lblLetter(10).Caption = "-"

lblLetter(11).Caption = "-"

lblLetter(0).Tag = Mid(Word, 1, 1)

lblLetter(1).Tag = Mid(Word, 2, 1)

lblLetter(2).Tag = Mid(Word, 3, 1)

Case 4

lblLetter(0).Caption = "& "

lblLetter(1).Caption = "& "

lblLetter(2).Caption = "& "

lblLetter(3).Caption = "& "

lblLetter(4).Caption = "-"

lblLetter(5).Caption = "-"

lblLetter(6).Caption = "-"

lblLetter(7).Caption = "-"

lblLetter(8).Caption = "-"

lblLetter(9).Caption = "-"

lblLetter(10).Caption = "-"

lblLetter(11).Caption = "-"

lblLetter(0).Tag = Mid(Word, 1, 1)

lblLetter(1).Tag = Mid(Word, 2, 1)

lblLetter(2).Tag = Mid(Word, 3, 1)

lblLetter(3).Tag = Mid(Word, 4, 1)

Case 5

lblLetter(0).Caption = "& "

lblLetter(1).Caption = "& "

lblLetter(2).Caption = "& "

lblLetter(3).Caption = "& "

lblLetter(4).Caption = "& "

lblLetter(5).Caption = "-"

lblLetter(6).Caption = "-"

lblLetter(7).Caption = "-"

lblLetter(8).Caption = "-"

lblLetter(9).Caption = "-"

lblLetter(10).Caption = "-"

lblLetter(11).Caption = "-"

lblLetter(0).Tag = Mid(Word, 1, 1)

lblLetter(1).Tag = Mid(Word, 2, 1)

lblLetter(2).Tag = Mid(Word, 3, 1)

lblLetter(3).Tag = Mid(Word, 4, 1)

lblLetter(4).Tag = Mid(Word, 5, 1)

Case 6

lblLetter(0).Caption = "& "

lblLetter(1).Caption = "& "

lblLetter(2).Caption = "& "

lblLetter(3).Caption = "& "

lblLetter(4).Caption = "& "

lblLetter(5).Caption = "& "

lblLetter(6).Caption = "-"

lblLetter(7).Caption = "-"

lblLetter(8).Caption = "-"

lblLetter(9).Caption = "-"

lblLetter(10).Caption = "-"

lblLetter(11).Caption = "-"

lblLetter(0).Tag = Mid(Word, 1, 1)

lblLetter(1).Tag = Mid(Word, 2, 1)

lblLetter(2).Tag = Mid(Word, 3, 1)

lblLetter(3).Tag = Mid(Word, 4, 1)

lblLetter(4).Tag = Mid(Word, 5, 1)

lblLetter(5).Tag = Mid(Word, 6, 1)

Case 7

lblLetter(0).Caption = "& "

lblLetter(1).Caption = "& "

lblLetter(2).Caption = "& "

lblLetter(3).Caption = "& "

lblLetter(4).Caption = "& "

lblLetter(5).Caption = "& "

lblLetter(6).Caption = "-"

lblLetter(7).Caption = "-"

lblLetter(8).Caption = "-"

lblLetter(9).Caption = "-"

lblLetter(10).Caption = "-"

lblLetter(11).Caption = "-"

lblLetter(12).Caption = "-"

lblLetter(0).Tag = Mid(Word, 1, 1)

lblLetter(1).Tag = Mid(Word, 2, 1)

lblLetter(2).Tag = Mid(Word, 3, 1)

lblLetter(3).Tag = Mid(Word, 4, 1)

lblLetter(4).Tag = Mid(Word, 5, 1)

lblLetter(5).Tag = Mid(Word, 6, 1)

lblLetter(6).Tag = Mid(Word, 7, 1)

Case 8

lblLetter(0).Caption = "& "

lblLetter(1).Caption = "& "

lblLetter(2).Caption = "& "

lblLetter(3).Caption = "& "

lblLetter(4).Caption = "& "

lblLetter(5).Caption = "& "

lblLetter(6).Caption = "& "

lblLetter(7).Caption = "& "

lblLetter(8).Caption = "-"

lblLetter(9).Caption = "-"

lblLetter(10).Caption = "-"

lblLetter(11).Caption = "-"

lblLetter(0).Tag = Mid(Word, 1, 1)

lblLetter(1).Tag = Mid(Word, 2, 1)

lblLetter(2).Tag = Mid(Word, 3, 1)

lblLetter(3).Tag = Mid(Word, 4, 1)

lblLetter(4).Tag = Mid(Word, 5, 1)

lblLetter(5).Tag = Mid(Word, 6, 1)

lblLetter(6).Tag = Mid(Word, 7, 1)

lblLetter(7).Tag = Mid(Word, 8, 1)

Case 9

lblLetter(0).Caption = "& "

lblLetter(1).Caption = "& "

lblLetter(2).Caption = "& "

lblLetter(3).Caption = "& "

lblLetter(4).Caption = "& "

lblLetter(5).Caption = "& "

lblLetter(6).Caption = "& "

lblLetter(7).Caption = "& "

lblLetter(8).Caption = "& "

lblLetter(9).Caption = "-"

lblLetter(10).Caption = "-"

lblLetter(11).Caption = "-"

lblLetter(0).Tag = Mid(Word, 1, 1)

lblLetter(1).Tag = Mid(Word, 2, 1)

lblLetter(2).Tag = Mid(Word, 3, 1)

lblLetter(3).Tag = Mid(Word, 4, 1)

lblLetter(4).Tag = Mid(Word, 5, 1)

lblLetter(5).Tag = Mid(Word, 6, 1)

lblLetter(6).Tag = Mid(Word, 7, 1)

lblLetter(7).Tag = Mid(Word, 8, 1)

lblLetter(8).Tag = Mid(Word, 9, 1)

Case 10

lblLetter(0).Caption = "& "

lblLetter(1).Caption = "& "

lblLetter(2).Caption = "& "

lblLetter(3).Caption = "& "

lblLetter(4).Caption = "& "

lblLetter(5).Caption = "& "

lblLetter(6).Caption = "& "

lblLetter(7).Caption = "& "

lblLetter(8).Caption = "& "

lblLetter(9).Caption = "& "

lblLetter(10).Caption = "-"

lblLetter(11).Caption = "-"

lblLetter(0).Tag = Mid(Word, 1, 1)

lblLetter(1).Tag = Mid(Word, 2, 1)

lblLetter(2).Tag = Mid(Word, 3, 1)

lblLetter(3).Tag = Mid(Word, 4, 1)

lblLetter(4).Tag = Mid(Word, 5, 1)

lblLetter(5).Tag = Mid(Word, 6, 1)

lblLetter(6).Tag = Mid(Word, 7, 1)

lblLetter(7).Tag = Mid(Word, 8, 1)

lblLetter(8).Tag = Mid(Word, 9, 1)

lblLetter(9).Tag = Mid(Word, 10, 1)

Case 11

lblLetter(0).Caption = "& "

lblLetter(1).Caption = "& "

lblLetter(2).Caption = "& "

lblLetter(3).Caption = "& "

lblLetter(4).Caption = "& "

lblLetter(5).Caption = "& "

lblLetter(6).Caption = "& "

lblLetter(7).Caption = "& "

lblLetter(8).Caption = "& "

lblLetter(9).Caption = "& "

lblLetter(10).Caption = "& "

lblLetter(11).Caption = "-"

lblLetter(0).Tag = Mid(Word, 1, 1)

lblLetter(1).Tag = Mid(Word, 2, 1)

lblLetter(2).Tag = Mid(Word, 3, 1)

lblLetter(3).Tag = Mid(Word, 4, 1)

lblLetter(4).Tag = Mid(Word, 5, 1)

lblLetter(5).Tag = Mid(Word, 6, 1)

lblLetter(6).Tag = Mid(Word, 7, 1)

lblLetter(7).Tag = Mid(Word, 8, 1)

lblLetter(8).Tag = Mid(Word, 9, 1)

lblLetter(9).Tag = Mid(Word, 10, 1)

lblLetter(10).Tag = Mid(Word, 11, 1)

Case 12

lblLetter(0).Caption = "& "

lblLetter(1).Caption = "& "

lblLetter(2).Caption = "& "

lblLetter(3).Caption = "& "

lblLetter(4).Caption = "& "

lblLetter(5).Caption = "& "

lblLetter(6).Caption = "& "

lblLetter(7).Caption = "& "

lblLetter(8).Caption = "& "

lblLetter(9).Caption = "& "

lblLetter(10).Caption = "& "

lblLetter(11).Caption = "& "

lblLetter(0).Tag = Mid(Word, 1, 1)

lblLetter(1).Tag = Mid(Word, 2, 1)

lblLetter(2).Tag = Mid(Word, 3, 1)

lblLetter(3).Tag = Mid(Word, 4, 1)

lblLetter(4).Tag = Mid(Word, 5, 1)

lblLetter(5).Tag = Mid(Word, 6, 1)

lblLetter(6).Tag = Mid(Word, 7, 1)

lblLetter(7).Tag = Mid(Word, 8, 1)

lblLetter(8).Tag = Mid(Word, 9, 1)

lblLetter(9).Tag = Mid(Word, 10, 1)

lblLetter(10).Tag = Mid(Word, 11, 1)

lblLetter(11).Tag = Mid(Word, 12, 1)

End Select

End Sub

تم تعديل هذه المشاركة بواسطة hanysaad في 3 يناير 2006 في 15:02

#2

بسم الله الرحمن الرحيم

الشيفرة بتتعامل مع مصفوفات تتحكم بحركة الشكل وظهور الصور لكن يا ريت لو تدرجي البرنامج كي يكون أوضح .

والسلام عليكم ورحمة الله وبركاته

********************* ******************** *********************

(( أشــهد أن لا اله الا الله ..... وأشهد أن محمد رسول الله ))

********************* ******************** *********************

لا تقـل من أيـن أبدأ

طـاعـة الله الـبدايـة

***

لا تقـل أين طـريـقي

شــرع الله الهـدايـة

***

لا تـقـل أيـن نعـيمي

جـنـة الله كـفـايـــــة

***

لا تقـل في الغـد أبدأ

ربمـــا تأتـي النهـايـــة

**************** **************** ****************

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

مواضيع مشابهة