用VB做一个小球移动的问题
用VB做一个小球移动的问题,代码是:Sub Form_KeyDown(keycode As Integer, shift As Integer)
Select Case keycode
Case vbKeyUp: Shape1.Move Shape1.Left, Shape1.Top - 100
Case vbKeyDown: Shape1.Move Shape1.Left, Shape1.Top + 100
Case vbKeyLeft: Shape1.Move Shape1.Left - 100, Shape1.Top
Case vbKeyRight: Shape1.Move Shape1.Left + 100, Shape1.Top
Case vbKeyUp And vbKeyLeft: Shape1.Move Shape1.Left - 100, Shape1.Top - 100
Case vbKeyUp And vbKeyRight: Shape1.Move Shape1.Left + 100, Shape1.Top - 100
Case vbKeyDown And vbKeyLeft: Shape1.Move Shape1.Left - 100, Shape1.Top + 100
Case vbKeyDown And vbKeyRight: Shape1.Move Shape1.Left + 100, Shape1.Top + 100
End Select
End Sub
怎样才能限制小球移动的区域?
顺便还问下,这个程序控制小球斜着走必须两个方向键同时按下去才可以,怎样才能优化成不管同不同时按下两个键就可以斜着走呢?