1
好吧,所以我想在VB6中为班级项目制作第三人称游戏,并且当人与墙(形状)碰撞时,他们不应该移动。但问题是,当人碰撞到墙壁时,它会停下来,但现在墙壁已经卡住,不会与所有其他墙壁一起滚动。这里是我的代码:在第三人称游戏中发生墙壁碰撞的困难VB6
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyLeft Or vbKeyRight Or vbKeyUp Or vbKeyDown Then
tmrMove.Enabled = True
End If
Select Case KeyCode
Case vbKeyLeft
XVel = 0 - Speed
YVel = 0
Case vbKeyRight
XVel = Speed
YVel = 0
Case vbKeyUp
YVel = 0 - Speed
XVel = 0
Case vbKeyDown
YVel = Speed
XVel = 0
End Select
Keys(KeyCode) = True
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Keys(KeyCode) = False
If Keys(vbKeyLeft) = False And Keys(vbKeyRight) = False And Keys(vbKeyUp) = False And Keys(vbKeyDown) = False Then
XVel = 0
YVel = 0
End If
End Sub
Private Sub tmrMove_Timer()
For i = 0 To (Wall.Count - 1)
If Collision(Character, Wall(i)) = False Then
Wall(i).Left = Wall(i).Left - XVel
Wall(i).Top = Wall(i).Top - YVel
End If
Next i
End Sub
Public Function Collision(Shape1 As ShockwaveFlash, Shape2 As Shape) As Boolean
If (Shape1.Left + Shape1.Width) > Shape2.Left And _
Shape1.Left < (Shape2.Left + Shape2.Width) And _
(Shape1.Top + Shape1.Height) > Shape2.Top And _
Shape1.Top < (Shape2.Top + Shape2.Height) Then
Collision = True
Else
Collision = False
End If
End Function
现在你可以看到,问题是,当发生碰撞时,我不知道HOWTO“uncollide”让我们与碰撞壁卡住,不会与其余滚动这些事。解释希望你理解是令人困惑的。由于
正如你所看到的,