Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net VisualBasic暴民AI漫游?_Vb.net - Fatal编程技术网

Vb.net VisualBasic暴民AI漫游?

Vb.net VisualBasic暴民AI漫游?,vb.net,Vb.net,现在我的暴徒只是随机移动,我需要它像30像素一样在海峡线上行走然后转弯,但我真的不知道从哪里开始 Function mob() Application.DoEvents() Randomize() Dim value As Integer = CInt(Int((4 * Rnd()) + 1)) If value = 1 Then ElseIf value = 2 Then If Me.mob2.Lo

现在我的暴徒只是随机移动,我需要它像30像素一样在海峡线上行走然后转弯,但我真的不知道从哪里开始

    Function mob()
        Application.DoEvents()
        Randomize()
        Dim value As Integer = CInt(Int((4 * Rnd()) + 1))
        If value = 1 Then
        ElseIf value = 2 Then
    If Me.mob2.Location.Y < 549 Then
        Me.mob2.Location = New Point(Me.mob2.Location.X, Me.mob2.Location.Y + 1)
    End If
        ElseIf value = 3 Then
    If Me.mob2.Location.X > 12 Then
        Me.mob2.Location = New Point(Me.mob2.Location.X - 1, Me.mob2.Location.Y)
    End If
        ElseIf value = 4 Then
    If Me.mob2.Location.X < 750 Then
        Me.mob2.Location = New Point(Me.mob2.Location.X + 1, Me.mob2.Location.Y)
    End If
        End If

End Function

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    mob()
End Sub

使用图形spath@Meatie你想得到图形方面的帮助吗?或者构建您的类\事件,例如,_Tick可以叫我.mob2.Move?或者只是一条直线的算法?我不知道。移动这个东西,我会研究一下,我至少还不喜欢图形,谢谢你的帮助。对于这个问题,我想让暴徒们直线移动20个像素,不要跳跃,一次移动一个像素的速度非常快,这样就可以真实地看到了。