Ce petit jeu consiste à trouver le bon code, d'où son nom.
On m'a dit que ce jeu était comme le 'Tirelien', où l'on doit trouver le bon chiffre en un certain nombre de coups.
Si le nombre que vous donnez est plus petit que le nombre à trouver, alors il vous est dit de donner un nombre plus grand.
Si le nombre que vous donnez est plus grand que le nombre à trouver, alors il vous est dit de donner un nombre plus petit.
Si vous trouvez le bon nombre, vous pouvez rejouer.
C'est un petit jeu pas trop compliqué (faut voir le niveau...), mais il faut quand même s'y mettre pour comprendre tout le code, même moi j'ai eu du mal a le modifié lorsque je le voulais.
La version 2 rajoute :
- l'option "click/reset", qui permet de recommencer le code même sans appuyer sur une touche;
- l'option "au hasard", qui permet de laisser le hasard trouver le code (ça ne le trouve pas souvent...);
- l'option "rejouer", qui permet de recommencer sans pour autant composer le code;
- l'option "Ancien code", qui permet d'afficher l'ancien code tapé, et en plus de rappeler si le code est plus grand ou plus petit;
- l'option "move form", qui permet de déplacer la fenêtre.
Source / Exemple :
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Private Sub Command0_Click()
codecmpse = codecmpse + "0"
End Sub
Private Sub Command1_Click()
codecmpse = codecmpse + "1"
End Sub
Private Sub Command10_Click()
If Combo1 = "4(défaut)" Then nbc = "1"
If Combo1 = "4" Then nbc = "1"
If Combo1 = "5" Then nbc = "10+9"
If Combo1 = "6" Then nbc = "100+99"
If Combo1 = "7" Then nbc = "1000+999"
If Combo1 = "8" Then nbc = "10000+9999"
For n = 1000 To (9999 * nbc)
Randomize
number = Int(n * Rnd)
Next n
If number < 1000 Then
For n = 1000 To (9999 * nbc)
Randomize
number = Int(n * Rnd)
Next n
End If
End Sub
Private Sub Command11_Click()
code = codecmpse
re.Visible = True
Timer2.Enabled = True
End Sub
Private Sub Command11_LostFocus()
If codecmpse < number Then
codevrf = "Ancien : " + codecmpse + " - " + "Le code est plus grand."
codecmpse = ""
re = ""
re.Visible = False
essais = essais - 1
End If
If codecmpse > number Then
codevrf = "Ancien : " + codecmpse + " - " + "Le code est plus petit."
codecmpse = ""
re = ""
re.Visible = False
essais = essais - 1
End If
If codecmpse = number Then
codevrf = ""
codecmpse = ""
re = ""
re.Visible = False
essais = "10"
For n = 1000 To (9999 * nbc)
Randomize
number = Int(n * Rnd)
Next n
End If
If number < 1000 Then
For n = 1000 To (9999 * nbc)
Randomize
number = Int(n * Rnd)
Next n
End If
Timer2.Enabled = False
End Sub
Private Sub Command12_Click()
For n = 1000 To (9999 * nbc)
Randomize
codecmpse = Int(n * Rnd)
Next n
If codecmpse < 1000 Then
For n = 1000 To (9999 * nbc)
Randomize
codecmpse = Int(n * Rnd)
Next n
End If
End Sub
Private Sub Command2_Click()
codecmpse = codecmpse + "2"
End Sub
Private Sub Command3_Click()
codecmpse = codecmpse + "3"
End Sub
Private Sub Command4_Click()
codecmpse = codecmpse + "4"
End Sub
Private Sub Command5_Click()
codecmpse = codecmpse + "5"
End Sub
Private Sub Command6_Click()
codecmpse = codecmpse + "6"
End Sub
Private Sub Command7_Click()
codecmpse = codecmpse + "7"
End Sub
Private Sub Command8_Click()
codecmpse = codecmpse + "8"
End Sub
Private Sub Command9_Click()
codecmpse = codecmpse + "9"
End Sub
Private Sub Form_Load()
Command12.Caption = "Au" + vbCrLf + "hasard"
code.Visible = False
re.Visible = False
essais = "10"
If Combo1 = "4(défaut)" Then nbc = "1"
If Combo1 = "4" Then nbc = "1"
If Combo1 = "5" Then nbc = "10+9"
If Combo1 = "6" Then nbc = "100+99"
If Combo1 = "7" Then nbc = "1000+999"
If Combo1 = "8" Then nbc = "10000+9999"
For n = 1000 To (9999 * nbc)
Randomize
number = Int(n * Rnd)
Next n
If number < 1000 Then
For n = 1000 To (9999 * nbc)
Randomize
number = Int(n * Rnd)
Next n
End If
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
ReleaseCapture
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Sub
Private Sub Label2_Click()
End
End Sub
Private Sub Label5_Click()
About.Show
End Sub
Private Sub Label6_Click()
essais = "10"
codecmpse = ""
codevrf = ""
re = ""
For n = 1000 To (9999 * nbc)
Randomize
number = Int(n * Rnd)
Next n
Timer2.Enabled = False
If number < 1000 Then
For n = 1000 To (9999 * nbc)
Randomize
number = Int(n * Rnd)
Next n
End If
End Sub
Private Sub Label7_Click()
triche.Show
End Sub
Private Sub re_Click()
re.Visible = False
If codecmpse < number Then
codevrf = "Ancien : " + codecmpse + " - " + "Le code est plus grand."
codecmpse = ""
re = ""
essais = essais - 1
End If
If codecmpse > number Then
codevrf = "Ancien : " + codecmpse + " - " + "Le code est plus petit."
codecmpse = ""
re = ""
essais = essais - 1
End If
If codecmpse = number Then
codevrf = ""
codecmpse = ""
re = ""
essais = "10"
For n = 1000 To (9999 * nbc)
Randomize
number = Int(n * Rnd)
Next n
End If
If number < 1000 Then
For n = 1000 To (9999 * nbc)
Randomize
number = Int(n * Rnd)
Next n
End If
Timer2.Enabled = False
End Sub
Private Sub Timer1_Timer()
If Combo1 = "4(défaut)" Then codecmpse.MaxLength = 4
If Combo1 = "4" Then codecmpse.MaxLength = 4
If Combo1 = "5" Then codecmpse.MaxLength = 5
If Combo1 = "6" Then codecmpse.MaxLength = 6
If Combo1 = "7" Then codecmpse.MaxLength = 7
If Combo1 = "8" Then codecmpse.MaxLength = 8
End Sub
Private Sub Timer2_Timer()
If codecmpse = number Then codevrf = "Le code est correct... Vous pouvez rejouer..." Else
If codecmpse > number Then codevrf = "Le code est incorrect... Il est plus petit..." Else
If codecmpse < number Then codevrf = "Le code est incorrect... Il est plus grand..."
re = "Cliquez ici ou composez un nouveau code..."
End Sub
Private Sub Timer3_Timer()
If essais = 0 Then
MsgBox "Vous n'avez plus d'essais disponibles, le jeu va donc se terminer.", vbOKOnly, "Plus d'essais restant"
End
End If
End Sub
Conclusion :
Ce programme n'est pas encore expliqué, ça ne saurait tarder...
Si toutefois vous avez des remarques, ou si vous voulez signaler un problème ou toute autre chose, dites-le moi. Merci
Je compte rajouter l'option "touches", qui permettra de taper le code à partir du clavier numérique...
À venir...