Morpion version 3

Description

Un petit jeu sympa...

Source / Exemple :


Dim grille(0 To 9, 0 To 9) As String
Dim tour As String

Private Sub Form_Load()
tour = "croix"
'For a = 0 To 101
'Image1(a).Picture = Image1(100)
'Next

End Sub

Private Sub Form_Unload(Cancel As Integer)
Do
reponse = MsgBox("Fabuleux, ce jeu, non?", vbYesNo + vbQuestion, "Vous nous quittez déjà?")
Loop While reponse <> vbYes
End Sub

Private Sub Image1_Click(Index As Integer)
y = Int(Index / 10)
x = Index - 10 * y
If grille(y, x) = "" Then
Image1(Index).Picture = Current(102).Picture
grille(y, x) = tour
If tour = "croix" Then tour = "ronds" Else tour = "croix"
End If
End Sub

Private Sub mnufichierapropos_Click()
MsgBox "Jeu de Morpion, par Nicolas Favre-Félix", vbOKOnly + vbInformation, "Morpion version 3"
End Sub

Private Sub mnufichierquitter_Click()
 Unload Form1
End Sub

Private Sub Timer1_Timer()
Testequijoue
Testequiagagné
End Sub

Private Sub Testequijoue()
If tour = "croix" Then Current(102) = Image1(100) Else: Current(102) = Image1(101)
End Sub

Private Sub Testequiagagné()
'horizontal
For yboucle = 0 To 9
For xboucle = 0 To 5
If grille(yboucle, xboucle) = "croix" And grille(yboucle, xboucle + 1) = "croix" And grille(yboucle, xboucle + 2) = "croix" And grille(yboucle, xboucle + 3) = "croix" And grille(yboucle, xboucle + 4) = "croix" Then croixgagne
If grille(yboucle, xboucle) = "ronds" And grille(yboucle, xboucle + 1) = "ronds" And grille(yboucle, xboucle + 2) = "ronds" And grille(yboucle, xboucle + 3) = "ronds" And grille(yboucle, xboucle + 4) = "ronds" Then rondsgagne
Next
Next

'vertical
For xboucle = 0 To 9
For yboucle = 0 To 5
If grille(yboucle, xboucle) = "croix" And grille(yboucle + 1, xboucle) = "croix" And grille(yboucle + 2, xboucle) = "croix" And grille(yboucle + 3, xboucle) = "croix" And grille(yboucle + 4, xboucle) = "croix" Then croixgagne
If grille(yboucle, xboucle) = "ronds" And grille(yboucle + 1, xboucle) = "ronds" And grille(yboucle + 2, xboucle) = "ronds" And grille(yboucle + 3, xboucle) = "ronds" And grille(yboucle + 4, xboucle) = "ronds" Then rondsgagne
Next
Next

'diagonal 1

For xboucle = 0 To 5
For yboucle = 4 To 9
If grille(yboucle, xboucle) = "croix" And grille(yboucle - 1, xboucle + 1) = "croix" And grille(yboucle - 2, xboucle + 2) = "croix" And grille(yboucle - 3, xboucle + 3) = "croix" And grille(yboucle - 4, xboucle + 4) = "croix" Then croixgagne
If grille(yboucle, xboucle) = "ronds" And grille(yboucle - 1, xboucle + 1) = "ronds" And grille(yboucle - 2, xboucle + 2) = "ronds" And grille(yboucle - 3, xboucle + 3) = "ronds" And grille(yboucle - 4, xboucle + 4) = "ronds" Then rondsgagne
Next
Next

'diagonal -1

For xboucle = 0 To 5
For yboucle = 0 To 5
If grille(yboucle, xboucle) = "croix" And grille(yboucle + 1, xboucle + 1) = "croix" And grille(yboucle + 2, xboucle + 2) = "croix" And grille(yboucle + 3, xboucle + 3) = "croix" And grille(yboucle + 4, xboucle + 4) = "croix" Then croixgagne
If grille(yboucle, xboucle) = "ronds" And grille(yboucle + 1, xboucle + 1) = "ronds" And grille(yboucle + 2, xboucle + 2) = "ronds" And grille(yboucle + 3, xboucle + 3) = "ronds" And grille(yboucle + 4, xboucle + 4) = "ronds" Then rondsgagne
Next
Next

nombre = 0
For xboucle = 0 To 9
For yboucle = 0 To 9
If grille(yboucle, xboucle) <> "" Then nombre = nombre + 1
Next
Next

If nombre = 100 Then MsgBox "EGALITE!!", vbExclamation + vbOKOnly, "Pas mal!!!"

End Sub
Private Sub croixgagne()
MsgBox "Les croix gagnent", vbOKOnly + vbExclamation, "Bien joué"
End
End Sub

Private Sub rondsgagne()
MsgBox "Les ronds gagnent", vbOKOnly + vbExclamation, "Bien joué"
End
End Sub

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.