65.9K
CodeProject 正在变化。 阅读更多。
Home

TextTwist1:一个模拟

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.73/5 (6投票s)

2012年3月30日

CPOL

5分钟阅读

viewsIcon

30728

downloadIcon

397

上瘾的时间。玩一个 Text Twist 的模拟版本(一个猜所有单词的游戏),在你的时间用完之前,输入“game”。

引言

你喜欢那种让你爱不释手的小游戏吗?试试这个...

背景

我正在玩 GameHouse™ Games 的 Super Text Twist®,但它总是崩溃。我运行的是 Windows7®™,而 Win7 不喜欢这个游戏。于是我决定开始制作自己的游戏版本,但不知道从何入手。我首先创建了所有要使用的窗体,然后开始在 PSC 上搜索代码,并偶然发现了一个由 Salan S. Al-Ani 制作的 VB 2005® beta express 版本。他的游戏版本可以在 PSC 上看到。我在我的版本中添加了更具视觉效果的元素。我还添加了得分、添加和删除高分的功能、待找单词的总数,以及根据使用 5、6 或 7 个字母单词的难度级别而变化的 3 到 7 个字母单词计数器。

使用代码

我尽量保持主窗体(见上图)与原版(参考 PSC®™ 上的程序)尽可能接近,但又不想完全照搬。我为应用程序添加了颜色和柔和的视觉效果,以获得更好的游戏体验(见上图)。所有背景都在 PS CS3®™ 中创建。我使用了一些来自 PSC 版本的旧代码,并对其进行了重新编辑和添加了大量代码,使其能够像原版(Super Text Twist®)一样工作。

移动窗体

我们开始吧。由于主窗体(见上图)和 Options 窗体(见下图)没有 TitleBar,我们需要一种方法在需要时移动它们。(代码将显示在下方)。所有其他窗体都是固定的。在全屏模式下,我们需要一种退出全屏模式的方法。我使用了一个闪烁的 Label 和一个 Timer 来向用户显示如何做到这一点。

'As we do not have a title bar, we will need to drag the form if we need to.
    Private Sub frmTextTwist_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Left Then
            Me.isDragging = True
            pointClicked = New Point(e.X, e.Y)
        Else
            Me.isDragging = False
        End If
    End Sub

    'This sub does the actual dragging of the form.
    Private Sub frmTextTwist_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        If Me.isDragging Then
            Dim pointMovedTo As Point
            pointMovedTo = Me.PointToScreen(New Point(e.X, e.Y))
            pointMovedTo.Offset(-pointClicked.X, -pointClicked.Y)
            Me.Location = pointMovedTo
        End If
    End Sub

    'This stops the dragging of the form.
    Private Sub frmTextTwist_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
        Me.isDragging = False
    End Sub

加载和退出全屏模式

 

如果你想以全屏模式玩游戏,只需在 Options 窗体中勾选 CheckBox,然后点击 CLOSE LABEL。这将加载全屏模式。加载后,你将看到一个闪烁的 LabelfrmTextTwist_KeyDown 事件在你按下键盘上的 Escape 键时触发。(以下是两个事件的代码)...

Private Sub frmTextTwist_SizeChanged(sender As Object, e As System.EventArgs) Handles Me.SizeChanged

        'Display a notice on how to exit Fullscreen mode.
        If Me.WindowState = FormWindowState.Maximized Then
            lblNotice.Location = New Point(CInt((Me.Width - lblNotice.Width) / 2), CInt((Me.Height - lblNotice.Height) / 2))
            lblNotice.Visible = True
            timerNotice.Start()
        Else
            lblNotice.Location = New Point(241, 229)
            lblNotice.Visible = False
            timerNotice.Stop()
        End If
    End Sub
	
	'timerNotice uses code for flashing the lblNotice
	Private Sub timerNotice_Tick(sender As Object, e As System.EventArgs) Handles timerNotice.Tick
        iTick += 1

        'To get the users attention...Flash the lable
        Select Case iTick
            Case 1
                lblNotice.ForeColor = Color.Black
            Case 2
                lblNotice.ForeColor = Color.White
            Case 3
                lblNotice.ForeColor = Color.Black
            Case 4
                lblNotice.ForeColor = Color.White
            Case 5
                lblNotice.ForeColor = Color.Black
        End Select

        If iTick = 5 Then
            iTick = 0
            lblNotice.Visible = False
            timerNotice.Stop()
        End If
    End Sub
	
	Private Sub frmTextTwist_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        'If we are in full screen mode only, we press the esc key to reset the window state to normal.
        If e.KeyData <> Keys.Escape Then
            'Do Nothing
        Else
            'The esc key was pressed.
            Me.WindowState = FormWindowState.Normal

            'Be sure we uncheck the checkbox in frmOptions.
            frmOptions.chkFullScreen.Checked = False
        End If
    End Sub

真黄油还是假黄油?

接下来,我们有按钮(Button1 到 Button7)的FAKE动画。这是通过设置一些 Points 并将一些 Booleans 设置为 TrueFalse 来实现的。接下来的代码对于所有七个按钮都相同,除了按钮名称。我们还将按钮文本添加到隐藏的 Label 中,以便在点击 Enter Button 时使用。

Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        If NowPlaying = True And FirstRun = False Then
            Dim s As String
            Select Case Difficulty
                Case 1
                    If AO1 = True And AO2 = False And AO3 = False And AO4 = False And AO5 = False And Button1.Location <> BL1 Then AO1 = False
                    If AO1 = True And AO2 = True And AO3 = False And AO4 = False And AO5 = False And Button1.Location <> BL1 Then AO2 = False
                    If AO1 = True And AO2 = True And AO3 = True And AO4 = False And AO5 = False And Button1.Location <> BL1 Then AO3 = False
                    If AO1 = True And AO2 = True And AO3 = True And AO4 = True And AO5 = False And Button1.Location <> BL1 Then AO4 = False
                    If AO1 = True And AO2 = True And AO3 = True And AO4 = True And AO5 = True And Button1.Location <> BL1 Then AO5 = False

                    If Button1.Location <> BL1 Then
                        Button1.Location = BL1
                        s = lblAnswer.Text
                        s = s.Replace(Button1.Text, "")
                        lblAnswer.Text = s
                        Exit Sub
                    End If

                    lblAnswer.Text += Button1.Text

                    If AO1 = False And AO2 = False And AO3 = False And AO4 = False And AO5 = False Then
                        Button1.Location = BL1a
                        AO1 = True
                    ElseIf AO1 = True And AO2 = False And AO3 = False And AO4 = False And AO5 = False Then
                        Button1.Location = BL2b
                        AO2 = True
                    ElseIf AO1 = True And AO2 = True And AO3 = False And AO4 = False And AO5 = False Then
                        Button1.Location = BL3c
                        AO3 = True
                    ElseIf AO1 = True And AO2 = True And AO3 = True And AO4 = False And AO5 = False Then
                        Button1.Location = BL4d
                        AO4 = True
                    ElseIf AO1 = True And AO2 = True And AO3 = True And AO4 = True And AO5 = False Then
                        Button1.Location = BL5e
                        AO5 = True
                    End If
                Case 2
                    If AO1 = True And AO2 = False And AO3 = False And AO4 = False And AO5 = False And AO6 = False And Button1.Location <> BL1 Then AO1 = False
                    If AO1 = True And AO2 = True And AO3 = False And AO4 = False And AO5 = False And AO6 = False And Button1.Location <> BL1 Then AO2 = False
                    If AO1 = True And AO2 = True And AO3 = True And AO4 = False And AO5 = False And AO6 = False And Button1.Location <> BL1 Then AO3 = False
                    If AO1 = True And AO2 = True And AO3 = True And AO4 = True And AO5 = False And AO6 = False And Button1.Location <> BL1 Then AO4 = False
                    If AO1 = True And AO2 = True And AO3 = True And AO4 = True And AO5 = True And AO6 = False And Button1.Location <> BL1 Then AO5 = False
                    If AO1 = True And AO2 = True And AO3 = True And AO4 = True And AO5 = True And AO6 = True And Button1.Location <> BL1 Then AO6 = False

                    If Button1.Location <> BL1 Then
                        Button1.Location = BL1
                        s = lblAnswer.Text
                        s = s.Replace(Button1.Text, "")
                        lblAnswer.Text = s
                        Exit Sub
                    End If

                    lblAnswer.Text += Button1.Text

                    If AO1 = False And AO2 = False And AO3 = False And AO4 = False And AO5 = False And AO6 = False Then
                        Button1.Location = BL1a
                        AO1 = True
                    ElseIf AO1 = True And AO2 = False And AO3 = False And AO4 = False And AO5 = False And AO6 = False Then
                        Button1.Location = BL2b
                        AO2 = True
                    ElseIf AO1 = True And AO2 = True And AO3 = False And AO4 = False And AO5 = False And AO6 = False Then
                        Button1.Location = BL3c
                        AO3 = True
                    ElseIf AO1 = True And AO2 = True And AO3 = True And AO4 = False And AO5 = False And AO6 = False Then
                        Button1.Location = BL4d
                        AO4 = True
                    ElseIf AO1 = True And AO2 = True And AO3 = True And AO4 = True And AO5 = False And AO6 = False Then
                        Button1.Location = BL5e
                        AO5 = True
                    ElseIf AO1 = True And AO2 = True And AO3 = True And AO4 = True And AO5 = True And AO6 = False Then
                        Button1.Location = BL6f
                        AO6 = True
                    End If
                Case 3
                    If AO1 = True And AO2 = False And AO3 = False And AO4 = False And AO5 = False And AO6 = False And AO7 = False And Button1.Location <> BL1 Then AO1 = False
                    If AO1 = True And AO2 = True And AO3 = False And AO4 = False And AO5 = False And AO6 = False And AO7 = False And Button1.Location <> BL1 Then AO2 = False
                    If AO1 = True And AO2 = True And AO3 = True And AO4 = False And AO5 = False And AO6 = False And AO7 = False And Button1.Location <> BL1 Then AO3 = False
                    If AO1 = True And AO2 = True And AO3 = True And AO4 = True And AO5 = False And AO6 = False And AO7 = False And Button1.Location <> BL1 Then AO4 = False
                    If AO1 = True And AO2 = True And AO3 = True And AO4 = True And AO5 = True And AO6 = False And AO7 = False And Button1.Location <> BL1 Then AO5 = False
                    If AO1 = True And AO2 = True And AO3 = True And AO4 = True And AO5 = True And AO6 = True And AO7 = False And Button1.Location <> BL1 Then AO6 = False
                    If AO1 = True And AO2 = True And AO3 = True And AO4 = True And AO5 = True And AO6 = True And AO7 = True And Button1.Location <> BL1 Then AO7 = False

                    If Button1.Location <> BL1 Then
                        Button1.Location = BL1
                        s = lblAnswer.Text
                        s = s.Replace(Button1.Text, "")
                        lblAnswer.Text = s
                        Exit Sub
                    End If

                    lblAnswer.Text += Button1.Text

                    If AO1 = False And AO2 = False And AO3 = False And AO4 = False And AO5 = False And AO6 = False And AO7 = False Then
                        Button1.Location = BL1a
                        AO1 = True
                    ElseIf AO1 = True And AO2 = False And AO3 = False And AO4 = False And AO5 = False And AO6 = False And AO7 = False Then
                        Button1.Location = BL2b
                        AO2 = True
                    ElseIf AO1 = True And AO2 = True And AO3 = False And AO4 = False And AO5 = False And AO6 = False And AO7 = False Then
                        Button1.Location = BL3c
                        AO3 = True
                    ElseIf AO1 = True And AO2 = True And AO3 = True And AO4 = False And AO5 = False And AO6 = False And AO7 = False Then
                        Button1.Location = BL4d
                        AO4 = True
                    ElseIf AO1 = True And AO2 = True And AO3 = True And AO4 = True And AO5 = False And AO6 = False And AO7 = False Then
                        Button1.Location = BL5e
                        AO5 = True
                    ElseIf AO1 = True And AO2 = True And AO3 = True And AO4 = True And AO5 = True And AO6 = False And AO7 = False Then
                        Button1.Location = BL6f
                        AO6 = True
                    ElseIf AO1 = True And AO2 = True And AO3 = True And AO4 = True And AO5 = True And AO6 = True And AO7 = False Then
                        Button1.Location = BL7g
                        AO7 = True
                    End If
            End Select
        End If
    End Sub

启动时加载词典

我们需要首先将词典加载到 4 个不同的 StreamReader 和 4 个不同的 FileInfo 持有者中。声明一个 integer 来保存这 4 个 FileInfo 持有者的总数,通过 Progressbar 向用户显示进度,声明一些 New ArrayLists 并开始将文件读取到数组中。然后清理并设置游戏计时器为 False,直到我们开始游戏。

Public Sub Startup()
        NowPlaying = False

        Dim line As String

        Dim MyReaderDicAll As System.IO.StreamReader
        Dim MyReaderDic5L As System.IO.StreamReader
        Dim MyReaderDic6L As System.IO.StreamReader
        Dim MyReaderDic7L As System.IO.StreamReader

        MyReaderDicAll = My.Computer.FileSystem.OpenTextFileReader(Application.StartupPath & "\Dic\DicAll.txt")
        MyReaderDic5L = My.Computer.FileSystem.OpenTextFileReader(Application.StartupPath & "\Dic\Dic5L.txt")
        MyReaderDic6L = My.Computer.FileSystem.OpenTextFileReader(Application.StartupPath & "\Dic\Dic6L.txt")
        MyReaderDic7L = My.Computer.FileSystem.OpenTextFileReader(Application.StartupPath & "\Dic\Dic7L.txt")

        Dim infoAll As System.IO.FileInfo
        Dim info5L As System.IO.FileInfo
        Dim info6L As System.IO.FileInfo
        Dim info7L As System.IO.FileInfo

        infoAll = My.Computer.FileSystem.GetFileInfo(Application.StartupPath & "\Dic\DicAll.txt")
        info5L = My.Computer.FileSystem.GetFileInfo(Application.StartupPath & "\Dic\Dic5L.txt")
        info6L = My.Computer.FileSystem.GetFileInfo(Application.StartupPath & "\Dic\Dic6L.txt")
        info7L = My.Computer.FileSystem.GetFileInfo(Application.StartupPath & "\Dic\Dic7L.txt")

        Dim max As Integer

        max = CInt(infoAll.Length + info5L.Length + info6L.Length + info7L.Length)

        PB_Loading.Style = ProgressBarStyle.Blocks
        PB_Loading.Minimum = 0
        PB_Loading.Maximum = max
        PB_Loading.Value = 0

        DicAll = New ArrayList
        line = MyReaderDicAll.ReadLine()
        While Not line Is Nothing
            PB_Loading.Value = PB_Loading.Value + line.Length + 2
            DicAll.Add(line.ToString)
            line = MyReaderDicAll.ReadLine()
        End While

        Dic5L = New ArrayList
        line = MyReaderDic5L.ReadLine()
        While Not line Is Nothing
            PB_Loading.Value = PB_Loading.Value + line.Length + 2
            Dic5L.Add(line.ToString)
            line = MyReaderDic5L.ReadLine()
        End While

        Dic6L = New ArrayList
        line = MyReaderDic6L.ReadLine()
        While Not line Is Nothing
            PB_Loading.Value = PB_Loading.Value + line.Length + 2
            Dic6L.Add(line.ToString)
            line = MyReaderDic6L.ReadLine()
        End While

        Dic7L = New ArrayList
        line = MyReaderDic7L.ReadLine()
        While Not line Is Nothing
            PB_Loading.Value = PB_Loading.Value + line.Length + 2
            Dic7L.Add(line.ToString)
            line = MyReaderDic7L.ReadLine()
        End While

        MyReaderDicAll.Close()
        MyReaderDic5L.Close()
        MyReaderDic6L.Close()
        MyReaderDic7L.Close()

        timerGame.Enabled = False
    End Sub

Enter 按钮

这里是程序大约 60% 的逻辑所在。首先,我们检查一些 Booleans 来确定是否退出 Sub。接下来,我们分别声明一些子程序变量(String, Integer 和 Boolean)。还记得我上面提到的隐藏 Label 吗?在这里,我们将我们(刚刚声明的)String 设置为隐藏 Label 的文本(lblAnswer)。接下来,我们将检查我们 String 的长度。如果 String 的长度小于 3 个字符,那么我们 Clear(稍后解释)所有内容并退出 Sub。否则,我们继续检查我们是否已经将 String 添加到 ListBox(lstCorrectWords)中,使用 StrCompare() 方法。如果我们的 String 在 ListBox 中,那么我们 Clear 所有内容,退出 sub,然后重新开始。否则,我们继续。如果单词长度不够、正确、已在 Listbox 中、是 ChoosenWord 或不是,都会向用户显示消息。所有单词计数器都会更新(如果单词是 3 个字母,则 (threeLetters -= 1)),依此类推,其他计数器也一样。如果找到了所有 PossibleWords,那么我们将进行大量清理工作,并按长度字母顺序向用户显示 ListBox 中的所有可能单词。你的分数也会显示出来。然后,我们通过按 Proceed Button 来继续游戏。

Private Sub btnEnter_Click(sender As System.Object, e As System.EventArgs) Handles btnEnter.Click
        If NowPlaying = False Or FirstRun = True Then
            Exit Sub
        End If

        Dim str As String
        Dim i As Integer
        Dim Okay As Boolean

        str = lblAnswer.Text

        If str.Length < 3 Then
            lblNotify.Text = "The word should be at least 3 letters long."
            Clear()
            Exit Sub
        End If

        For i = 0 To lstCorrectWords.Items.Count - 1
            If StrComp(lstCorrectWords.Items(i).ToString, str, CompareMethod.Text) = 0 Then
                lblNotify.Text = "You already submitted this word (" & str & ")"
                Clear()
                Exit Sub
            End If
        Next i

        Okay = False
        For i = 0 To PossibleWords.Count - 1
            If StrComp(str, PossibleWords.Item(i).ToString, CompareMethod.Text) = 0 Then
                Okay = True
                Exit For
            End If
        Next i

        If Okay = True Then
            If str.Length = 4 + Difficulty And str = ChoosenWord Then
                lblNotify.Text = "Excellent (" & str & ")"
                scoreTotal += 1500
                totalWords -= 1
                lblWordsToFind.Text = "Number of words to find ====>> " & totalWords.ToString

                If Difficulty = 3 And str = ChoosenWord Then
                    sevenLetters -= 1
                    lblWordsWithSevenLetters.Text = "Words with 7 letters : " & sevenLetters.ToString()
                ElseIf Difficulty = 2 And str = ChoosenWord Then
                    sixLetters -= 1
                    lblWordsWithSixLetters.Text = "Words with 6 letters : " & sixLetters.ToString()
                ElseIf Difficulty = 1 And str = ChoosenWord Then
                    fiveLetters -= 1
                    lblWordsWithFiveLetters.Text = "Words with 5 letters : " & fiveLetters.ToString()
                End If

                btnProceed.Enabled = True
            Else
                lblNotify.Text = "Correct Word (" & str & ")"

                If str.Length = 3 Then
                    scoreTotal += 250
                    totalWords -= 1
                    lblWordsToFind.Text = "Number of words to find ====>> " & totalWords.ToString
                    threeLetters -= 1
                    lblWordsWithThreeLetters.Text = "Words with 3 letters : " & threeLetters.ToString()
                ElseIf str.Length = 4 Then
                    scoreTotal += 500
                    totalWords -= 1
                    lblWordsToFind.Text = "Number of words to find ====>> " & totalWords.ToString
                    fourLetters -= 1
                    lblWordsWithFourLetters.Text = "Words with 4 letters : " & fourLetters.ToString()
                ElseIf str.Length = 5 Then
                    scoreTotal += 750
                    totalWords -= 1
                    lblWordsToFind.Text = "Number of words to find ====>> " & totalWords.ToString
                    fiveLetters -= 1
                    lblWordsWithFiveLetters.Text = "Words with 5 letters : " & fiveLetters.ToString()
                ElseIf str.Length = 6 Then
                    scoreTotal += 1000
                    totalWords -= 1
                    lblWordsToFind.Text = "Number of words to find ====>> " & totalWords.ToString
                    sixLetters -= 1
                    lblWordsWithSixLetters.Text = "Words with 6 letters : " & sixLetters.ToString()
                ElseIf str.Length = 7 Then
                    scoreTotal += 1500
                    totalWords -= 1
                    lblWordsToFind.Text = "Number of words to find ====>> " & totalWords.ToString
                    sevenLetters -= 1
                    lblWordsWithSevenLetters.Text = "Words with 7 letters : " & sevenLetters.ToString()
                End If
            End If

            lstCorrectWords.Items.Add(str)

            If lstCorrectWords.Items.Count = PossibleWords.Count Then
                lblNotify.Text = "Excellent, you submitted all the possible words"
                totalWords = 0
                lblWordsToFind.Text = "Number of words to find ====>> " & totalWords.ToString
                NowPlaying = False
                GameTimerSec = 0
                lblTimeHolder.Text = "0:00"
                timerGame.Enabled = False
                RedoList()
                ShowWords()
                Exit Sub
            End If
        Else
            lblNotify.Text = "Sorry, this word is not supported in our dictionary (" & str & ")"
        End If

        lblScoreHolder.Text = scoreTotal.ToString() 'Display the user's score
        Clear()
    End Sub

清除、排序、洗牌和扭转,这就是我们“这样做”的方式

Clear sub 将 lblAnswer 重置为 Nothing,将(Button1 到 Button7)的 EnabledLocation Properties 设置为 True 和各自的位置,并将其 Booleans 设置为 True

Public Sub Clear()
        lblAnswer.Text = ""
        Button1.Enabled = True
        Button2.Enabled = True
        Button3.Enabled = True
        Button4.Enabled = True
        Button5.Enabled = True
        Button6.Enabled = True
        Button7.Enabled = True

        Button1.Location = BL1
        Button2.Location = BL2
        Button3.Location = BL3
        Button4.Location = BL4
        Button5.Location = BL5
        Button6.Location = BL6
        Button7.Location = BL7

        AO1 = False
        AO2 = False
        AO3 = False
        AO4 = False
        AO5 = False
        AO6 = False
        AO7 = False
    End Sub

现在我们对所有放入我们声明的 ArrayLists 中的单词进行排序。这是数组列表...

  • threeLetterWords
  • fourLetterWords
  • fiveLetterWords
  • sixLetterWords
  • sevenLetterWords

我们根据单词的长度对所有单词进行排序。然后它们会按照长度的字母顺序显示在 ListBox 中。这是通过大量的 For...Next Loops 来完成的。

Private Sub RedoList()
        lstCorrectWords.Items.Clear()
        Dim i As Integer

        For i = 0 To PossibleWords.Count - 1
            If PossibleWords(i).ToString.Length = 3 Then
                threeLetterWords.Add(PossibleWords(i))
            End If
        Next i

        threeLetterWords.Sort()

        For i = 0 To PossibleWords.Count - 1
            If PossibleWords(i).ToString.Length = 4 Then
                fourLetterWords.Add(PossibleWords(i))
            End If
        Next i

        fourLetterWords.Sort()

        For i = 0 To PossibleWords.Count - 1
            If PossibleWords(i).ToString.Length = 5 Then
                fiveLetterWords.Add(PossibleWords(i))
            End If
        Next i

        fiveLetterWords.Sort()

        For i = 0 To PossibleWords.Count - 1
            If PossibleWords(i).ToString.Length = 6 Then
                sixLetterWords.Add(PossibleWords(i))
            End If
        Next i

        sixLetterWords.Sort()

        For i = 0 To PossibleWords.Count - 1
            If PossibleWords(i).ToString.Length = 7 Then
                sevenLetterWords.Add(PossibleWords(i))
            End If
        Next i

        sevenLetterWords.Sort()

    End Sub
	
	Private Sub ShowWords()
        Dim i As Integer

        For i = 0 To threeLetterWords.Count - 1
            lstCorrectWords.Items.Add(threeLetterWords(i))
        Next

        For i = 0 To fourLetterWords.Count - 1
            lstCorrectWords.Items.Add(fourLetterWords(i))
        Next

        For i = 0 To fiveLetterWords.Count - 1
            lstCorrectWords.Items.Add(fiveLetterWords(i))
        Next

        For i = 0 To sixLetterWords.Count - 1
            lstCorrectWords.Items.Add(sixLetterWords(i))
        Next

        For i = 0 To sevenLetterWords.Count - 1
            lstCorrectWords.Items.Add(sevenLetterWords(i))
        Next
    End Sub

在下一个 sub(Twist)中所做的一切就是将字母重新排列,使它们不再与之前的按钮相同。

Public Sub Twist()
        Dim AlReadyPicked() As Integer
        Dim PickedSeq() As Integer
        Dim LetterCount As Integer
        Dim i As Integer
        Dim j As Integer
        Dim rndNo As Integer
        Dim Okay As Boolean

        LetterCount = Difficulty + 4
        ReDim AlReadyPicked(LetterCount)
        ReDim PickedSeq(LetterCount)

        For j = 0 To LetterCount - 1
            PickedSeq(j) = 0
        Next j

        Randomize()
        For i = 0 To LetterCount - 1
            Do
                rndNo = CInt(Int(LetterCount * Rnd()) + 1)
                Okay = True
                For j = 0 To LetterCount - 1
                    If rndNo = PickedSeq(j) Then
                        Okay = False
                        Exit For
                    End If
                Next j
                If Okay = True Then
                    PickedSeq(i) = rndNo
                    Exit Do
                End If
            Loop
        Next i

        Button1.Text = Mid(ChoosenWord, PickedSeq(0), 1)
        Button2.Text = Mid(ChoosenWord, PickedSeq(1), 1)
        Button3.Text = Mid(ChoosenWord, PickedSeq(2), 1)
        Button4.Text = Mid(ChoosenWord, PickedSeq(3), 1)
        Button5.Text = Mid(ChoosenWord, PickedSeq(4), 1)

        If Difficulty = 2 Then
            Button6.Text = Mid(ChoosenWord, PickedSeq(5), 1)
        ElseIf Difficulty = 3 Then
            Button6.Text = Mid(ChoosenWord, PickedSeq(5), 1)
            Button7.Text = Mid(ChoosenWord, PickedSeq(6), 1)
        End If
    End Sub

结论

虽然这个游戏以前也有过,但你需要付费。现在你不需要了。玩起来很有趣,但有时又不那么有趣,因为你没有足够的时间来完成你的单词并按下 Enter 来获得最后一个单词。我本想延长时限,但,“aaaaa”。那样就不好玩了。玩得开心。投票...我只是把这个放到网站上,供任何想抓狂的人使用。

关注点

世界史,第一部分。

  • 首次完成 2012.03.30
© . All rights reserved.