Private Sub Controle_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown For Each Control In Me.Controls If e.KeyCode = Keys.Q AndAlso Control IsNot Boule Then Control.Location = New Point(Control.left + 20, Control.top) ElseIf e.KeyCode = Keys.D AndAlso Control IsNot Boule Then Control.Location = New Point(Control.left - 20, Control.top) ElseIf e.KeyCode = Keys.Z AndAlso Control IsNot Boule Then Control.Location = New Point(Control.left, Control.top + 20) ElseIf e.KeyCode = Keys.S AndAlso Control IsNot Boule Then Control.Location = New Point(Control.left, Control.top - 20) End If Next If AnciennePlateforme.Tag = "Gauche" And AnciennePlateforme.Left > -100 Then Plateformes() Else If AnciennePlateforme.Tag = "Droite" And AnciennePlateforme.Left < 100 Then Plateformes() Else If AnciennePlateforme.Tag = "Haut" And AnciennePlateforme.Top > -20 Then Plateformes() End If End If End If End Sub
Public Class Form1 Dim ToucheUp As Boolean Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown ToucheUp = False Do For Each Control In Me.Controls Application.DoEvents() If Control IsNot Boule Then If e.KeyCode Keys.Q Then Control.Location New Point(Control.left - 1, Control.top) If e.KeyCode Keys.D Then Control.Location New Point(Control.left + 1, Control.top) If e.KeyCode Keys.Z Then Control.Location New Point(Control.left, Control.top - 1) If e.KeyCode Keys.S Then Control.Location New Point(Control.left, Control.top + 1) End If Next Loop Until ToucheUp = True End Sub Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp ToucheUp = True End Sub End Class
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question