English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

6 answers

Hi!

Visual basic is a simple program to do this in. Here is some code from an example in my class to help you write it. Keep in mind, this code references objects on a form that I named. You'd have to name your objects exactly the same to use this code. You're definitely better off to trace it, and re-write it for yourself.

Good Luck!

Option Explicit On
Option Strict On

Public Class MainForm

Private Sub xFileExitMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xFileExitMenuItem.Click
Me.Close()

End Sub

Private Sub xFileNewMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xFileNewMenuItem.Click
' simulates the Hangman game

Dim word As String
Dim letter As String
Dim isDashReplaced As Boolean
Dim isGameOver As Boolean
Dim incorrectCounter As Integer

' hide the picture boxes
Me.xBottomPictureBox.Visible = False
Me.xPostPictureBox.Visible = False
Me.xTopPictureBox.Visible = False
Me.xRopePictureBox.Visible = False
Me.xHeadPictureBox.Visible = False
Me.xBodyPictureBox.Visible = False
Me.xRightArmPictureBox.Visible = False
Me.xLeftArmPictureBox.Visible = False
Me.xRightLegPictureBox.Visible = False
Me.xLeftLegPictureBox.Visible = False

' get a 5-letter word from the first player
Do
word = InputBox("Enter a 5-letter word:", "Hangman Game")
Loop Until word.Length = 5

' convert the word to uppercase
word = word.ToUpper

' display five dashes in the xWordLabel
' and clear the xIncorrectLabel
Me.xWordLabel.Text = "-----"
Me.xIncorrectLabel.Text = String.Empty

' allow the second player to guess a letter
' the game is over when the second player
' either guesses the word or makes 10
' incorrect guesses
Do Until isGameOver
' get a letter from the second player, then
' convert the letter to uppercase
letter = InputBox("Enter a letter:", _
"Letter", "", 450, 400)
letter = letter.ToUpper

' search the word for the letter
For indexnum As Integer = 0 To 4
' if the word contains the letter, then
' replace the dash in the xWordLabel and
' assign True to isDashReplaced to
' indicate that a replacement was made
If word.Substring(indexnum, 1) = letter Then
Mid(Me.xWordLabel.Text, indexnum + 1) _
= letter
isDashReplaced = True
End If
Next indexnum

' determine whether a dash was replaced
If isDashReplaced Then
' if the word does not contain any dashes,
' the game is over because the second
' player guessed the word; otherwise, reset
' the isDashReplaced variable for the next
' search
If Me.xWordLabel.Text.Contains("-") = False Then
isGameOver = True
MessageBox.Show("Great guessing!", _
"Hangman Game", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
Else
isDashReplaced = False
End If

Else ' processed when no dash was replaced
' display the incorrect letter, then update
' the incorrectCounter variable, then show
' the appropriate picture box
Me.xIncorrectLabel.Text = _
Me.xIncorrectLabel.Text & " " & letter
incorrectCounter = incorrectCounter + 1
Select Case incorrectCounter
Case 1
Me.xBottomPictureBox.Visible = True
Case 2
Me.xPostPictureBox.Visible = True
Case 3
Me.xTopPictureBox.Visible = True
Case 4
Me.xRopePictureBox.Visible = True
Case 5
Me.xHeadPictureBox.Visible = True
Case 6
Me.xBodyPictureBox.Visible = True
Case 7
Me.xRightArmPictureBox.Visible = True
Case 8
Me.xLeftArmPictureBox.Visible = True
Case 9
Me.xRightLegPictureBox.Visible = True
Case 10
Me.xLeftLegPictureBox.Visible = True
isGameOver = True
MessageBox.Show("Sorry, the word is " _
& word & ".", "Hangman Game", _
MessageBoxButtons.OK, _
MessageBoxIcon.Information)
End Select
End If
Loop
End Sub
End Class

2006-10-15 15:53:56 · answer #1 · answered by Rob 3 · 0 0

Easiest: Macromedia Flash

Best: Using Visual C#

Good idea: try Visual basic (VB.net) or the gamer's version darkbasic http://www.darkbasic.com

Darkbasic is meant for creating games, but has a steep learning curve, and even at the best, you can't do as good as you could with C#. For hangman, flash or darkbasic is the way to go.

2006-10-15 11:56:27 · answer #2 · answered by ? 2 · 0 0

Macromedia Flash

2006-10-15 10:45:17 · answer #3 · answered by Padma 3 · 0 0

Hangman? Hangman is still best with simple pencil and paper.

2006-10-15 10:44:22 · answer #4 · answered by Fun and Games 4 · 0 0

Visual Basic for simpler games, but for more complex games you might want to try C++ (Visual or not) or Java

2006-10-15 11:00:06 · answer #5 · answered by hackmaster_sk 3 · 0 0

you could try Visual basics

2006-10-15 10:49:44 · answer #6 · answered by D@ve 3 · 0 0

fedest.com, questions and answers