Thread: [VB] Hangman Game (Console Application)

Results 1 to 3 of 3
  1. #1 [VB] Hangman Game (Console Application) 
    Gunner4Life [VB] Hangman Game (Console Application) Market Banned



    Join Date
    Jun 2011
    Posts
    2,357
    Thanks given
    132
    Thanks received
    667
    Rep Power
    648
    THIS IS NOT FOR BEGINNERS

    Hey guys,

    I have been working on Visual basic a lot recently and would like to share my code.

    Here it is:

    Humid's Hangman
    Code:
    Module Hangman
        'Author = Humid
        Dim deductlife, arrayvalue, wordlength, random, i As Integer
        Dim lives As Integer = 6
        Dim word, wordset(8), invisible, answer As String
        Dim inuse(25), character As Char
    
        Sub Main()
            Rules()
            Words()
            Randomiser()
            Hide()
            Game()
        End Sub
    
        Private Sub Rules()
            lives = 6
            deductlife = 1
            Console.WriteLine(" Space Hangman Rules: ")
            Console.WriteLine(" 1. You will have to guess letters of different planets in our solar system.")
            Console.WriteLine(" 2. You will have 6 lives in total and everytime you guess wrong, a life will be deducted.")
            Console.WriteLine(" 3. If you run out of lives then: `Rule 5")
            Console.WriteLine(" 4. If you correct the guess planet then: `Rule 6")
            Console.WriteLine(" 5. You are going back to planet earth.")
            Console.WriteLine(" 6. You have won your space adventure.")
            Console.WriteLine(" Press enter to contintue... ")
            Console.ReadLine()
        End Sub
    
        Private Sub Words()
            wordset(1) = "Mercury"
            wordset(2) = "Venus"
            wordset(3) = "Earth"
            wordset(4) = "Mars"
            wordset(5) = "Jupiter"
            wordset(6) = "Saturn"
            wordset(7) = "Uranus"
            wordset(8) = "Neptune"
        End Sub
     
       Private Sub Randomiser()
            Randomize()
            random = CInt(Int((4 * Rnd()) + 0))
            word = wordset(random)
        End Sub
    
        Private Sub Hide()
            wordlength = Len(word)
            For i As Integer = 1 To wordlength
                invisible = invisible & "*"
            Next
        End Sub
    
        Private Sub Game()
            deductlife = 1
            Console.Clear()
            Console.WriteLine(wordset(random))
            Console.WriteLine(" Please start geussing")
            character = Console.ReadLine()
            For i As Integer = 0 To 25
                If character = inuse(i) Then
                    Alert()
                End If
            Next
            AddingValue()
        End Sub
    
        Private Sub AddingValue()
            arrayvalue = arrayvalue + 1
            inuse(arrayvalue) = character
            CorrectGuess()
        End Sub
     
       Private Sub CorrectGuess()
            For i As Integer = 1 To wordlength
                If character = Mid(word, i, 1) Then
                    Mid(invisible, i, 1) = character
                    deductlife = 0
                End If
            Next
            If deductlife = 1 Then
                lives = lives - 1
                Console.WriteLine(" Your adventure is coming to an end! You have lost a life! ")
                Console.WriteLine(" You have" & lives & "lives remaining. ")
                Console.ReadLine()
            End If
            If invisible = word Then
                Victory()
            ElseIf lives = 0 Then
                Defeat()
            End If
            Game()
        End Sub
    
        Private Sub Alert()
            Console.WriteLine(" You have already used this letter and can not use it again.")
            Console.ReadLine()
        End Sub
    
        Private Sub Victory()
            Console.Clear()
            Console.BackgroundColor = ConsoleColor.DarkBlue
            Console.ForegroundColor = ConsoleColor.White
            Console.WriteLine(" You have completed your space adventure, well done! ")
            Console.WriteLine(" *_*")
            Console.WriteLine(" \|/")
            Console.WriteLine("  |")
            Console.WriteLine(" / \")
            Console.Clear()
            Console.WriteLine("Enter `Y/N` if you would like to play again")
            answer = Console.ReadLine()
            If answer = "y" Or answer = "Y" Then
                Main()
    
            ElseIf answer = "n" Or answer = "N" Then
                End
    
            Else
                Console.WriteLine("You must enter a valid answer")
                Victory()
            End If
        End Sub
    
        Private Sub Defeat()
            Console.Clear()
            Console.BackgroundColor = ConsoleColor.DarkGreen
            Console.ForegroundColor = ConsoleColor.White
            Console.WriteLine(" You have lost! ")
            Console.WriteLine(" O_O")
            Console.WriteLine(" /|\")
            Console.WriteLine("  |")
            Console.WriteLine(" / \")
            Console.Clear()
            Console.WriteLine("Enter `Y/N` if you would like to play again")
            answer = Console.ReadLine()
            If answer = "y" Or answer = "Y" Then
                Main()
    
            ElseIf answer = "n" Or answer = "N" Then
                End
    
            Else
                Console.WriteLine("You must enter a valid answer")
                Victory()
            End If
        End Sub
    
    End Module
    Reply With Quote  
     

  2. #2  
    Registered Member
    maffia-rpg's Avatar
    Join Date
    Jul 2011
    Posts
    2,775
    Thanks given
    587
    Thanks received
    759
    Rep Power
    120
    Why vb.net, at least use C#.
    Quote Originally Posted by Nando View Post
    why would I care about trying to get you to care about me homosexual?
    back to coding shit revisions
    1080% lost.
    Reply With Quote  
     

  3. #3  
    Gunner4Life [VB] Hangman Game (Console Application) Market Banned



    Join Date
    Jun 2011
    Posts
    2,357
    Thanks given
    132
    Thanks received
    667
    Rep Power
    648
    Cba

    This was quick and easy
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [C#] Console Application, loading internally [/C#]
    By TomTheBeast in forum Application Development
    Replies: 1
    Last Post: 04-24-2012, 11:43 AM
  2. PC or Console gaming?
    By Valkynaz in forum Voting
    Replies: 3
    Last Post: 03-26-2009, 08:05 AM
  3. Favorite Gaming Console?
    By TheJoker in forum Voting
    Replies: 11
    Last Post: 05-26-2008, 04:29 PM
  4. favorite game console?
    By Codeman in forum Voting
    Replies: 14
    Last Post: 05-08-2008, 01:57 PM
  5. Replies: 8
    Last Post: 03-09-2008, 01:26 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •