Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class EnglishGame
- 'Initialise Variables
- Dim TheGuessWord() As Char
- 'Stores the six letter word used’
- Dim TheAreaWhereTheGuessIsStored() As Char
- 'Stores the detector allowing the player to win’
- Dim Guess As Char
- 'Stores the letter the player guessed’
- Dim GuessesLeft As Integer
- 'Stores the number of guesses a player has left’
- Dim ThePossibleWords() As String
- 'Stores the words that are possible’
- Dim TheRandomNumber As Integer
- 'Stores a randomly generated number that selects the word used’
- Dim DidYouWin As Boolean
- 'Determines whether the player won or not’
- Dim Blanks() As Char
- 'Shows the player a series of 6 blanks to slowly be replaced by letters’
- Dim Counter2 As Integer
- 'counter 2'
- Private RandomNumber As New Random
- 'generates a random number'
- 'Starts the programme'
- Private Sub StartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartButton.Click
- GuessLabel.Text = "_ _ _ _ _ _"
- GuessButton.Enabled = True
- 'set ThePossibleWords
- ThePossibleWords = {"absurd", "common", "carpet", "damson", "escape", "eating", "factor", "guitar", "magnet", "magpie"}
- 'Sets number of guesses and the winning parameters as well as lays the foudation for guessing
- GuessesLeft = 10
- TheAreaWhereTheGuessIsStored = "______"
- Blanks = "_ _ _ _ _ _"
- 'Generate Random Number
- TheRandomNumber = RandomNumber.Next(10)
- 'sets word'
- TheGuessWord = ThePossibleWords(TheRandomNumber)
- 'test MsgBox, uncomment if it needs to be used to test
- 'MsgBox(TheGuessWord)
- End Sub
- Private Sub GuessBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles GuessBox.Click
- 'Makes a message inside the textbox disappear on click
- GuessBox.Text = " "
- End Sub
- Private Sub GuessButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GuessButton.Click
- 'fills in the blanks according to the guess imputed
- Guess = GuessBox.Text
- Dim Counter As Integer
- Counter = 0
- DidYouWin = False
- For Each N In TheGuessWord
- If N = Guess Then
- TheAreaWhereTheGuessIsStored(Counter2) = N
- DidYouWin = True
- 'uncomment if testing required
- 'MsgBox(TheAreaWhereTheGuessIsStored)
- End If
- Counter2 = Counter2 + 1
- Next
- For Each C In TheGuessWord
- Counter2 = 0
- If C = Guess Then
- Blanks(Counter * 2) = C
- DidYouWin = True
- 'uncomment if testing required
- ' MsgBox(TheAreaWhereTheGuessIsStored)
- GuessLabel.Text = Blanks
- End If
- Counter = Counter + 1
- 'uncomment for testing
- 'MsgBox(Counter & " " & Counter2)
- Next
- If DidYouWin = False Then
- GuessesLeft -= 1
- GuessLabel2.Text = GuessesLeft
- End If
- 'Helps the player know if they have won or lost
- If GuessesLeft <= 0 Then
- MsgBox("You Lose " & TheGuessWord & " was The word")
- MsgBox("try again")
- GuessButton.Enabled = False
- End If
- If TheAreaWhereTheGuessIsStored = TheGuessWord Then
- MsgBox("You Win, Yay!!!!")
- GuessButton.Enabled = False
- End If
- End Sub
- Private Sub GuessLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GuessLabel.Click
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement