想讨教一个关于键盘的上下左右键问题?
这阵子我在做一个移动游戏,是用键盘的上下左右键是实现的,但我想用W,S,A,D来显示上下左右问题,比喻我下面的代码是上下左右的代码,
Select Case e.KeyCode
Case 37
PictureBox1.Left = PictureBox1.Left - 48
x = x - 1
If PictureBox1.Left < 48 Then
PictureBox1.Left = 0
x = 0
End If
K(7 * y + x).Image = System.Drawing.Image.FromFile(CurDir() & "\tk\k.bmp")
If pd(7 * y + x) = 1 Then
pd(7 * y + x) = 2
js1 = js1 - 1
End If
If pd(7 * y + x) = -1 Then
pd(7 * y + x) = 3
js2 = js2 - 1
End If
Case 38
y = y - 1
PictureBox1.Top = PictureBox1.Top - 48
If PictureBox1.Top < 48 Then
PictureBox1.Top = 0
y = 0
End If
' Call pd()
K(7 * y + x).Image = System.Drawing.Image.FromFile(CurDir() & "\tk\k.bmp")
If pd(7 * y + x) = 1 Then
pd(7 * y + x) = 2
js1 = js1 - 1
End If
If pd(7 * y + x) = -1 Then
pd(7 * y + x) = 3
js2 = js2 - 1
End If
Case 39
x = x + 1
PictureBox1.Left = PictureBox1.Left + 48
If PictureBox1.Left > 48 * 6 Then
PictureBox1.Left = 48 * 6
x = 6
End If
' Call pd()
K(7 * y + x).Image = System.Drawing.Image.FromFile(CurDir() & "\tk\k.bmp")
If pd(7 * y + x) = 1 Then
pd(7 * y + x) = 2
js1 = js1 - 1
End If
If pd(7 * y + x) = -1 Then
pd(7 * y + x) = 3
js2 = js2 - 1
End If
Case 40
y = y + 1
PictureBox1.Top = PictureBox1.Top + 48
If PictureBox1.Top > 48 * 6 Then
PictureBox1.Top = 48 * 6
y = 6
End If
' Call pd()
K(7 * y + x).Image = System.Drawing.Image.FromFile(CurDir() & "\tk\k.bmp")
If pd(7 * y + x) = 1 Then
pd(7 * y + x) = 2
js1 = js1 - 1
End If
If pd(7 * y + x) = -1 Then
pd(7 * y + x) = 3
js2 = js2 - 1
End If
End Select
有谁可以告诉我W,S,A,D在Vb2005中是用哪个代码显示的。
[解决办法]
wsad分别为:87 83 65 68
其实在form_keydown事件中查看keycode即可。