Pendu en vb net

Description

Voici un petit pendu créer par moi ,
Il y a même un formulaire de connexion (pour l'instant il ne sert pas a grand chose mais plus tard je stockerais le nombre de parti jouer , perdu et gagner ) .

Source / Exemple :


(Je ne peut afficher tout le code source donc je ne montrerai que la partie la plus importante )

 Private Sub P_TraiterLettresLabels(ByVal sender As Object, ByVal e As System.EventArgs) _
            Handles ALabel.Click, BLabel.Click, CLabel.Click, DLabel.Click, ELabel.Click, _
            FLabel.Click, GLabel.Click, HLabel.Click, ILabel.Click, JLabel.Click, _
            KLabel.Click, LLabel.Click, MLabel.Click, NLabel.Click, OLabel.Click, _
            PLabel.Click, QLabel.Click, RLabel.Click, SLabel.Click, TLabel.Click, _
            ULabel.Click, VLabel.Click, WLabel.Click, XLabel.Click, YLabel.Click, ZLabel.Click

        'Déclaration des variables
        Dim objImage As New PictureBox
        Dim objLettreLabel As Label
        Dim intIndex As Integer
        Dim blnRemplace As Boolean
        Dim strMotPartiel, strcaractere As String

        Motlabel.Text = mStrgMots

        'Cache la lettre sélectionnée
        objLettreLabel = sender
        objLettreLabel.Visible = False

        strMotPartiel = MotCodeBox.Text

        'Instruction pour chercher si le caractère est dans le mot

        For intIndex = 0 To mintLongMot - 1
            strcaractere = mStrgMots.Substring(intIndex, 1)
            If strcaractere = objLettreLabel.Text Then
                Mid(strMotPartiel, intIndex + 1) = objLettreLabel.Text
                blnRemplace = True
            End If
        Next intIndex
        If blnRemplace = True Then
            If strMotPartiel.IndexOf("-") > -1 Then
                Me.MotCodeBox.Text = strMotPartiel
            Else
                mintnbJeuGagnant += 1
                Me.MotCodeBox.Text = mStrgMots
                mintCompteursFautes = 0
                LettresGroupBox.Visible = False
                MessageBox.Show("Bien joué!", "Jeu du pendu", _
                    MessageBoxButtons.OK, MessageBoxIcon.Information)
                RejouerButton.Visible = True
                chronotimer.Stop()
            End If
        Else
            mintCompteursFautes = mintCompteursFautes + 1
            If mintCompteursFautes = 7 Then
                mintnbjeuErreur += 1
                If mintnbjeuErreur = 5 Then
                    MessageBox.Show("Conseil : il faudrait que tu ouvre ton dico.")
                End If
                If mintnbjeuErreur = 8 Then
                    MessageBox.Show("Conseil : Après l'avoir ouvert , genéralement faut lire le dico.")
                End If
                If mintnbjeuErreur = 10 Then
                    MessageBox.Show("Conseil : Donc tu sais pas lire?")
                End If
                LettresGroupBox.Visible = False
                MessageBox.Show("Désolé, le mot était " & mStrgMots, "Jeu du pendu", _
                     MessageBoxButtons.OK, MessageBoxIcon.Information)
                RejouerButton.Visible = True
                chronotimer.Stop()

            End If
        End If

        Select Case mintCompteursFautes

            Case Is = 1
                objImage.BackgroundImage = PenduPictureBox2.BackgroundImage
            Case Is = 2
                objImage.BackgroundImage = PenduPictureBox3.BackgroundImage
            Case Is = 3
                objImage.BackgroundImage = PenduPictureBox4.BackgroundImage
            Case Is = 4
                objImage.BackgroundImage = PenduPictureBox5.BackgroundImage
            Case Is = 5
                objImage.BackgroundImage = PenduPictureBox6.BackgroundImage
            Case Is = 6
                objImage.BackgroundImage = PenduPictureBox7.BackgroundImage
            Case Is = 7
                objImage.BackgroundImage = PenduPictureBox8.BackgroundImage
        End Select
        PenduPictureBox.BackgroundImage = objImage.BackgroundImage

    End Sub

Conclusion :


Pour ceux qui veulent jouer a un petit pendu =)

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.