Soyez le premier à donner votre avis sur cette source.
Vue 16 957 fois - Téléchargée 742 fois
'Auteur : Gabriel Hautclocq ' Public Class Main Private touches As New Hashtable() Private time As Single Private score As Integer Private rndTouche As Integer Private trouve As Boolean = True Private encours As Boolean = False Private mode As Integer Private Const duree As Single = 30 Private Sub Main_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing Arreter() End Sub Private Sub Main_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click If Not encours Then Demarrer() Else Arreter() End If End Sub Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click If Not encours Then Demarrer() Else Arreter() End If End Sub Private Sub Main_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown If encours Then If e.KeyData.ToString() = touches(rndTouche) Then trouve = True score = score + 1 My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Exclamation) Else score = score - 1 My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Hand) End If Label3.Text = "Score : " & score Else If e.KeyData = Keys.Enter Or e.KeyData = Keys.Return Then Demarrer() End If End If End Sub Private Sub initialisation() touches.Clear() Dim currentMode As Integer = getMode() 'Mode de base touches.Add(1, "A") touches.Add(2, "B") touches.Add(3, "C") touches.Add(4, "D") touches.Add(5, "E") touches.Add(6, "F") touches.Add(7, "G") touches.Add(8, "H") touches.Add(9, "I") touches.Add(10, "J") touches.Add(11, "K") touches.Add(12, "L") touches.Add(13, "M") touches.Add(14, "N") touches.Add(15, "O") touches.Add(16, "P") touches.Add(17, "Q") touches.Add(18, "R") touches.Add(19, "S") touches.Add(20, "T") touches.Add(21, "U") touches.Add(22, "V") touches.Add(23, "W") touches.Add(24, "X") touches.Add(25, "Y") touches.Add(26, "Z") touches.Add(27, "Space") If currentMode > 1 Then 'Mode Laptop touches.Add(28, "F1") touches.Add(29, "F2") touches.Add(30, "F3") touches.Add(31, "F4") touches.Add(32, "F5") touches.Add(33, "F6") touches.Add(34, "F7") touches.Add(35, "F8") touches.Add(36, "F9") touches.Add(37, "F10") touches.Add(38, "F11") touches.Add(39, "F12") touches.Add(40, "Up") touches.Add(41, "Down") touches.Add(42, "Left") touches.Add(43, "Right") If currentMode > 2 Then 'Mode Expert touches.Add(44, "NumPad0") touches.Add(45, "NumPad1") touches.Add(46, "NumPad2") touches.Add(47, "NumPad3") touches.Add(48, "NumPad4") touches.Add(49, "NumPad5") touches.Add(50, "NumPad6") touches.Add(51, "NumPad7") touches.Add(52, "NumPad8") touches.Add(53, "NumPad9") touches.Add(54, "NumLock") End If End If End Sub Private Function getMode() As Integer Dim lemode As Integer = 1 If R1.Checked Then lemode = 1 ElseIf R2.Checked Then lemode = 2 ElseIf R3.Checked Then lemode = 3 End If Return lemode End Function Private Sub Demarrer() time = duree score = 0 Label2.Text = "Time : " & duree & "s" Label3.Text = "Score : 0" Timer.Start() encours = True While time > 0 Application.DoEvents() If trouve Then Randomize() rndTouche = CInt(Int((touches.Count * Rnd()) + 1)) trouve = False Label1.Text = touches(rndTouche).ToString End If End While Timer.Stop() encours = False trouve = True Label1.Text = "Ready ?" End Sub Private Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer.Tick time = time - 0.1 If time < 0 Then time = 0 Label2.Text = "Time : " & CSng(CInt(time * 10)) / 10 & "s" End Sub Private Sub Arreter() time = 0 End Sub Private Sub R1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles R1.CheckedChanged If R1.Checked Then initialisation() End If End Sub Private Sub R2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles R2.CheckedChanged If R2.Checked Then initialisation() End If End Sub Private Sub R3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles R3.CheckedChanged If R3.Checked Then initialisation() End If End Sub Private Sub Main_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LostFocus Me.Focus() End Sub End Class
18 nov. 2005 à 18:43
18 nov. 2005 à 07:12
A++
Nexto (fabienfs)
18 nov. 2005 à 01:48
des fois on oublie de le remettre, ça fait descendre le score, je trouve ça bien hehe!
ça permet de corser le jeu !
17 nov. 2005 à 21:57
A++
Nexto
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.